In this article, you will learn about the Python string istitle() method.istitle function in Python returns True if all the words in a string start with Uppercase otherwise return False.
In the previous tutorial, we have seen Python string isspace() to check a string contains only spaces or not.
Headings of Contents
Python string istitle() method
Python string istitle() method is a string method that is Return True if all the words in the string start with uppercase and rest of the letters in lowercase, Otherwise return False.
Syntax
The syntax of string istitle function in python is:-
string.istitle()
Parameter
istitle function in Python does not support any parameter.
Return Type
Python string istitle() method return only True or False.
Python string istitle example
Here will write some Python code to understand string istitle function in python.
Example 1:
str = "Programming 123 Funda"
str2 = str.istitle()
print(str2)
Output will be:- True
Example 2:
str = "12 Python"
str2 = str.istitle()
print(str2)
Output will be:- True
Example 3:
str = "Hello World"
str2 = str.istitle()
print(str2)
Output will be:- True
Example 4
str = "Python programming"
str2 = str.istitle()
print(str2)
Output will be:- False
Example 5:
str = 'Programming'
if str.istitle():
print("Your string is title case")
else:
print("Something wrong")
Output will be:- “Your string is title case“
Note:- Python string istitle method ignore numbers and symbols.
Conclusion
Here, you have learned all about the Python string istitle() method along with some examples. This is the best way to check all the words in string starts with uppercase or not.
I hope this article will have helped you. If you like this artice, please share it with your friends who want to learn Python programming.
- String endswith() method
- String casefold() method
- String center() method
- String capitalize() method
- String count() method
- String index() method
- String format() method
- String isalpha() method
- String isidentifier() method
- String islower() method
- String isupper() method
For More Information:- Click Here