my_str.istitle()
Returns True if all words in a string starts with upper case letter , otherwise returns False
my_str='Welcome To Python'
print(my_str.istitle()) # Output is True
my_str='Welcome to Python'
print(my_str.istitle()) # Output is False
my_str='WELCOME TO PYTHON'
print(my_str.istitle()) # Output is False ( All letters in Upper case )
my_str='Welcome to python'
print(my_str.istitle()) # False ( All words are not starting with upper case)
my_str='100 Welcome'
print(my_str.istitle()) # True
my_str = "123 Welcome"
print(my_str.istitle()) # Output: True (numbers don't affect title case)
title = input("Enter title: ")
if title.istitle():
print("Title is correctly formatted")
else:
print("Incorrect title format")
my_str = "Hello World"
print(my_str.istitle()) # Output: True
my_str = "hello World"
print(my_str.istitle()) # Output: False (First word is lowercase)
my_str = "Python@3 Rocks!"
print(my_str.istitle()) # Output: True (Special characters are ignored)
my_str = "Python@rocks"
print(my_str.istitle()) # Output: False (Rocks is not title-cased)
empty_str = ""
print(empty_str.istitle()) # Output: False
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.