KnowledgeBoat Logo
|

Computer Science

Write the Python statement and the output for the following:

(a) Find the third occurrence of 'e' in 'sequence'.

(b) Change the case of each letter in string 'FuNcTioN'.

(c) Whether 'Z' exists in string 'School' or not.

Python String Manipulation

1 Like

Answer

(a)

s = 'sequence'
index = s.find('e', s.find('e', s.find('e') + 1) + 1)
print(index)
Output
7

(b)

s = 'FuNcTioN'
print(s.swapcase())
Output
fUnCtIOn

(c)

s = 'School'
print('Z' in s)
Output
False

Answered By

1 Like


Related Questions