For this, we use the method isalnum().
Q.14. How will you capitalize the first letter of a string?
Simply using the method capitalize().
>>> 'ayushi'.capitalize()
‘Ayushi’
>>> type(str.capitalize)
<class ‘method_descriptor’>
However, it will let other characters be.
>>> '@yushi'.capitalize()
‘@yushi’
>>> 'Ayushi123'.isalnum()
True
>>> 'Ayushi123!'.isalnum()
False
Other methods that we have include:
>>> '123.3'.isdigit()
False
>>> '123'.isnumeric()
True
>>> 'ayushi'.islower()
True
>>> 'Ayushi'.isupper()
False
>>> 'Ayushi'.istitle()
True
>>> ' '.isspace()
True
>>> '123F'.isdecimal()
False