Python String isidentifier() Method

Python isidentifier() method is used to check whether a string is a valid identifier or not. It returns True if the string is a valid identifier otherwise returns False.

Python language has own identifier definition which is used by this method.

Signature

Parameters

No parameter is required.

Return

It returns either True or False.

Let's see some examples of isidentifier() method to understand it's functionalities.

Python String isidentifier() Method Example 1

A simple Example to apply isidentifier() method, it returns True. See the example.

Output:

True

Python String isidentifier() Method Example 2

Here, we have created variety of identifiers. Some returns True and some False. See the example below.

Output:

True
False
False

Python String isidentifier() Method Example 3

This method is useful in decision making therfore can be used with if statement.


Next TopicPython Strings




Latest Courses