Use the istitle()
method to check if the first character in every word in a string is upper case and the other characters are lower case.
text = 'This is a regular text'
print(text.istitle())
#output: False
text = 'This Is A Regular Text'
print(text.istitle())
#output: True
text = 'This $ Is @ A Regular 3 Text!'
print(text.istitle())
#output: True
If you notice the last example, the numbers and special characters like @
and $
in the string make no difference and istitle()
still returns True
because the method only verifies the alphabetical characters.