×

Python String istittle() method

Python String istittle() method

The string.istittle() method returns a boolean value true if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise.

Syntax

string.istitle()

Parameter

NA

Return

This method returns a Boolean value True if the string is a titlecased string else it returns False.

Example 1

 # Python program explaining
 # the istitle() method
 # In the given string the first character in each word is  
 # uppercase and remaining all are in lowercases 
 string = "My Favourite Teacher"
 print("String 1:",string)
 # will return true
 print("The above string is Titlecased:",string.istitle()) 
 # First character in first word is lowercase 
 string = "geeks For Geeks"
 print("String 2:",string)
 print("The above string is Titlecased:",string.istitle()) 
 # Third word has uppercase 
 # characters at middle 
 string = "My favourite TEACHER"
 print("String 3:",string)
 print("The above string is Titlecased:",string.istitle()) 
 # paasing the first word as integer and in rest the first character in each word is  
 # uppercase and remaining all are in lowercases
 string = "6041 Is My Lucky Number"
 print("String 4:",string)
 print("The above string is Titlecased:",string.istitle()) 
 # All the characters are in uppercase 
 string = "TUTORIALS"
 print("String 5:",string)
 print("The above string is Titlecased:",string.istitle()) 

Output

 String 1: My Favourite Teacher
 The above string is Titlecased: True
 String 2: geeks For Geeks
 The above string is Titlecased: False
 String 3: My favourite TEACHER
 The above string is Titlecased: False
 String 4: 6041 Is My Lucky Number
 The above string is Titlecased: True
 String 5: TUTORIALS
 The above string is Titlecased: False 

Example 2

 # Python program explaining
 # the istitle() method
 string = "I Love Python Programming"
 print("String 1:",string)
  # validating if else condition
 if string.istitle() == True: 
     print('The above string is Titlecased\n') 
 else: 
     print('The above string is Not a Titlecased String\n') 
 string = "I love Python programing"
 print("String 2:",string)
 # validating if else condition
 if string.istitle() == True: 
     print('The above string is Titlecased') 
 else: 
     print('The above string is Not a Titlecased String') 

Output

 String 1: I Love Python Programming
 The above string is Titlecased
 String 2: I love Python programing
 The above string is Not a Titlecased String 

Related Topics

Decision Tree Classification in Python

In this article, we will learn the implementation of the decision tree in Sklearn, which is nothing but the Scikit Learn library of python. First, we should learn what classification...

12 minutes read.

Difference between For Loop and While Loop in Python

What is the “For” loop? The “For” Loop is a commonly used control structure in programming that allows us to repeat a set of actions multiple times. The “For” loop is...

3 minutes read.

Python Program to Check Leap Year

Python Program to Check Leap Year Leap year: We all know that each year has 365 or 366 days. But whenever a year has 366 days, then the year is said...

2 minutes read.

Uint8 Python

Python: Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It is said...

3 minutes read.

How to check version of Python

How to check version of python The versions of Python come with different kinds of features and functionalities. It is not a herculean task to keep track of the updates these...

3 minutes read.

Python data science course

What is meant by Data Science? When processing raw, structured, and unstructured data utilizing various technologies, algorithms, and the scientific method, data science is a detailed study of the enormous quantity...

4 minutes read.

How To Compare Two Strings In Python

In this article, we will discuss how to compare two strings in Python. So, before that, let’s have a quick revision on “What are strings?” Strings are a sequence of characters that...

5 minutes read.

GUI to Shut down, Restart and Logout from the PC using Tkinter in Python

GUI: One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs...

4 minutes read.

How to slice a list in python

When working with lists, we face situations where we may need a part of the list from one index to the other. Slicing is one of the simpler ways to...

5 minutes read.

Python List pop() method

Python List pop() method The list.pop() method removes the item at the specified position in the list, and return it. If no index is specified, this method removes and returns the last item in the list. Syntax list.pop([i]) Parameter i:...

1 minute read.

How to import numy in python

How to Install NumPy in Python Python is a vast ocean of libraries, modules, and different functions. It has a solution for almost everything. Using Python, we can simplify even a...

3 minutes read.

Python Identifiers

Identifiers in Python User-defined names are identifiers in Python that are used to name variables, functions, classes, modules, and other things. You can create Python identifiers using these rules: As an identifier...

4 minutes read.

Python setattr() function

Python setattr() function The setattr() function sets the value of the specified attribute of the specified object. Syntax setattr(object, name, value) Parameter object: This parameter represents any object. name: This parameter represents the name of the attribute you...

1 minute read.

Python Unit Test Cheat String

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Multiprocessing in python

The word multiprocessing is used to compute the operation in which more than two processors run simultaneously with more than one central processor. The computer's performance increases gradually. Multiprocessing is...

6 minutes read.

Python List append() Method

Python List append() Method The list.append() method in Python adds or appends an item to the end of the list. Syntax list.append(x) Parameter x: It is a required parameter that represents an element of any type (string, number,...

1 minute read.

Python elif

Python elif The elif statement is used to check multiple conditions and execute the specific block of statements depending upon the true condition among them. Syntax if expression1: statement elif expression2: statement elif expression3: statement else: statement The elif statement can be optional...

3 minutes read.

Python Set update() method

Python Set update() method The set.update() method in Python updates the current set, by adding items from another set. If an element is common in both the sets, only one appearance of this item...

1 minute read.

Python String join() method

Python String join() method The String.join() method in Python concatenates each element of an iterable (such as list, string and tuple) to the given string and returns the concatenated string. Syntax string.join(seq) Parameter Seq: This...

1 minute read.

YOLO Python

YOLO means you only look once.It is a technique to perform object detection is called YOLO. It is the algorithmused by the program to identify items in the image. Earlier detection...

4 minutes read.