×

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

How To Print Colored Text in Python

Changing the colour of certain parts of a string when printing the output of a Python programme to the terminal may make it easier to read. We can approach this...

3 minutes read.

How to run a Program in Python

How to run a Program in Python Writing a program in Python is an easy task, beginners who are ready to kickstart their career in the world of programming can create...

3 minutes read.

Python Kwargs Example

In this article, we'll talk about Python's kwargs notion. In Python, kwargs has two stars and passes a variable number of keyworded argument lists to the function, whereas args has...

5 minutes read.

Python Glob

Methods for matching files that include particular patterns in accordance with UNIX shell-related expansion rules are referred to as "glob" methods. Similar methods for finding, locating, and searching for all of...

12 minutes read.

Python Word Tokenizer

Python Overview Python is an Object-Oriented high-level language. Python is designed to be highly beginner-friendly. Python has an English-like syntax, which is very easy to read. Python is an interpreted language...

4 minutes read.

Standard GUI Unit Converter using PyQt5 in Python

GUI: A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast...

6 minutes read.

Text detection using Tkinter in Python

Tkinter: The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is...

4 minutes read.

How to Import Files in 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.

How to print in the same line in Python?

How to print in the same line in python By default, the print function in Python takes us to the next line and prints the desired statement in the output. In this...

5 minutes read.

How to Install Python

Python Installation Guide Step by Step Installing Python is quite simple and easy. In this tutorial, we will show stepwise procedure to install Python and set up the Python environment in different...

2 minutes read.

Python Project Ideas

One of the most widely used programming languages today is Python. This pattern appears set to continue through 2023 and beyond. Therefore, working on some current Python project ideas is the...

10 minutes read.

Loan calculator using Tkinter in Python

Tkinter: Tkinter, part of all common Python distributions, is the de facto method for creating Graphical User Interfaces (GUIs) in Python. The only framework included in the Python standard library is...

4 minutes read.

Socket Programming in Python

Socket Programming in Python In this tutorial, we will discuss network programming using Python programming language. We will explore all basic concept of network with Python script. Network Services in Python Python has...

9 minutes read.

Flutter Python

The flutter is a frame work available in the python programming language, to create web applications, mobile apps. The flutter is generally used for the development of the backend of...

3 minutes read.

Binary Search Visualization using Pygame in Python

A calculation like Binary Search is seen effectively by picturing. Here in this tutorial, a function that pictures the Binary Search Algorithm is carried out. The Graphical User’s Interface (GUI)...

15 minutes read.

Python String replace() method

Python String replace() method The string.replace() method in Python returns a copy of the string with all occurrences of substring old replaced by new. Syntax replace(old, new[, count]) Parameter old: This parameter represents a substring you want to...

2 minutes read.

Python TypeError

What is TypeError in python? TypeError is one of the exceptions in the python programming language. This exception occurs when an operation is performed on an unsupported object type or can...

6 minutes read.

Arithmetic Expressions in Python

What is Python Expression? Expressions are collections of operands and operators. Python expressions are translated by the Python interpreter into some value or outcome. In Python, an expression is made up...

13 minutes read.

Important Difference between Python 2.x and Python 3.x with Example

The comparison between Python 2 and Python 3 is given in the article that follows. Python is a computer language that can perform more tasks than other languages and is...

5 minutes read.

Python SQLite

SQLite It is an RDBMS (Relational Database Management System). It is an embedded, serverless, transactional SQL database engine. It is an open-source application. It is named SQLite because of its lightweight....

3 minutes read.