⊗pyPmIBSSe 182 of 208 menu

Searching Strings in Python

startswith endswith find index rfind rindex count replace

Given a string:

txt = 'abcdef'

Check if this string starts with 'ac'.

Given a list:

lst = ['12', '13', '14', '15']

Check if its elements start with '1'.

Given a number:

num = 123456

Check if there is a six at the end.

Given a string:

txt = 'abcdef'

Find the index of the symbol 'c'.

Given a string:

txt = 'ab1cd1ef'

Find the index of the character '1', while searching from the third to the seventh character of the string.

Given a string:

txt = '123453637'

Find the index of the last match of the symbol '3'.

Given a string:

txt = '2025.12.31'

Find the index of the last match of the character '2'.

Given a number:

num = 24536589

Find out how many fives are in it.

Given a list:

lst = ['abc', 'cde', 'cbb', 'aeb']

Find out how many 'b' symbols are in each of its elements.

Given a string:

txt = 'http1://code.mu'

Write the code to get the following result:

txt = 'https://code.mu'

Given a string:

txt = 'a.bc.d.ef'

Replace all periods in it with spaces.

byenru