Page 233 - Robotics and AI class 10
P. 233
find(str,star t, It returns the index of the first >>> S="Hello, how are you?"
end) occurrence of a substring inside a >>> S. find("el")
string if it is found. If not found, it
returns -1. 1
>>> S.find(El")
Syntax is:
-1
String.find(Substring,Start,
>>> S.find(how')
End+1)
7
Where Start and End are optional. If
not given then the searching starts >>> S.find('How')
from index 0 to index last. -1
>>> S.find('o',5,10)
8
islower() It returns True if the string contains >>> S1="Class10B"
at least one lowercase letter and no >>> S1.islower()
uppercase at all.
False
>>> 'hello'.islower()
True
isupper() It returns True if the string contains >>> S2="WORLD"
at least one uppercase letter and no >>> S2.isupper()
lowercase at all.
True
>>> S1="Class10B"
>>> S1.isupper()
False
isalpha() It returns True if the string contains >>> S1="Class10B"
only alphabets >>> S1.isalpha()
False
>>> S2="WORLD"
>>> S2.isalpha()
True
isalnum() It returns True if the string contains >>> S1="Class10B"
only alphanumeric(alphabets or >>> S1.isalnum()
digits)
True
>>> S2="Class10-B"
>>> S2.isalnum()
False
isdigit() It returns True if the string contains >>> S1="Class10B"
only digits >>> S1.isdigit()
False
>>> S3="123"
>>> S3.isdigit()
True
Introduction to Data and Programming with Python 231

