Python String isidentifier() Method Tutorial

In this section we will learn what String isidentifier() method is and how to use it in Python.

What is String isidentifier() Method in Python?

The Python string isidentifier() method is used to see if a string value is a valid identifier.

This means the content only contains alphabet, numbers, and underscores `_` and the string starts with either alphabet characters or `_`.

Python String isidentifier() Method Syntax:

string.isidentifier()

String isidentifier() Method Parameter

The method does not take an argument.

String isidentifier() Method Return Value

The return value of this method is of type boolean.

The value True will return if the target string is a valid identifier.

Otherwise, the value False will return instead.

Example: using python string isidentifier() method

s1= "223434533"

s2 = "_id"

print(s1.isidentifier())

print(s2.isidentifier())

Output:

False

True
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies