×

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

Python lock

Before understanding the concept of Python-lock we need to understand what kind if condition we require to implement the locks in Python. Let us start with multithreading and its implementation...

5 minutes read.

Python Banner

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.

iobase Python

All I/O flow classes derive from this conceptual base class. Derived classes will have to execute several of the class's abstract data types. The loop method is supported by all members of...

4 minutes read.

Python Fit Transform

In machine learning, fit (), transform(), fit transform () methods are provided by scikit learn package. This package is used in model fitting and data processing. These methods are implemented...

2 minutes read.

List Subtract in Python

The List is one of the most unique Data Structures in Python. It is generally used to store multiple values in just one single variable. It is one of the...

4 minutes read.

Python | Read csv using pandas.read_csv()

Python is an excellent language for performing information analysis, owing to the fantastic biological system of information-driven python packages. Pandas is one of those packages that make taking in and...

4 minutes read.

Periodogram in 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.

Time. Sleep() in Python

Python time sleep () function suspends execution for a certain seconds given by user. Time sleep () syntax: Sleep(seconds) Limitations: The number of seconds to be suspends the code as per its requirements. Returns: Void The execution...

3 minutes read.

What does base case mean in recursion

Base cases and recursive stages are used to define recursive functions. In a primary subject, we compute the outcome right away, given the function call's arguments. In a recursive step, we...

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.

How to Update Python?

How to Update Python In this article, we will discuss how we can update Python in our system. For a better understanding, this article will cover all the steps right from installation...

4 minutes read.

How to Convert Int to String in Python?

Every value we use or store in a variable in Python will have a specific data type. It describes the value's nature; based on that, Python will automatically assign a...

4 minutes read.

Shallow Copy and Deep Copy in Python

Shallow Copy and Deep Copy in Python In this section, we will learn about the Shallow Copy and Deep Copy in the Python program. But before going through the topic, we...

6 minutes read.

Python Setup guide and installation

Python Installation guide Step by Step Python is widely used high-level programming language. The first version of Python was launched in 1991. Since then, Python has been gaining popularity. It is considered as...

4 minutes read.

Python program to convert Celsius into Fahrenheit

Python program to convert Celsius into Fahrenheit This program explains how we can take the temperature in Celsius and convert them into Fahrenheit. Celsius Celsius, also known as centigrade, is a measurement unit...

1 minute read.

Python PyMOTW

The cmd module comprises one class of the general public, Cmd, meant for command processors such interactive shells and other command interpreters as a foundation class. It utilises readline as...

3 minutes read.

Python String rstrip() method

Python String rstrip() method The string.rstrip() method in Python returns a copy of the string with trailing characters removed. Syntax string.rstrip([chars]) Parameter chars:  This argument represents a string specifying the set of characters to be...

1 minute read.

Run exec python from PHP

PHP (which is a recursive abbreviation for PHP Hypertext Preprocessor) is one of the most broadly involved web improvement innovations on the planet. PHP code utilized for creating sites and...

4 minutes read.

Find whether the given stringnumber is palindrome or not

Problem statement Sam is found of playing with strings. One day he thought of finding whether a string is a palindrome or not. He wanted to develop a computer process to...

2 minutes read.

Python String isalpha() method

Python String isalpha() method The string.isalpha () method in Python returns a boolean value true if all characters in the  string are alphabetic else for any other value it returns false. Syntax isalpha()  Parameter NA Return This...

1 minute read.