Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




isidentifier( ) FUNCTION


isidentifier() Function


The isidentifier() Function is used to check if the String is a valid identifier.


Note : Just for recap, a valid identifier is the one that contains alphanumeric characters (A to Z or a to z) or numbers (0 to 9) or an underscore. An identifier can never start with a number.

Example :


x = "24A"
if x.isidentifier():
    print("Is an Identifier")
else:
    print("Is not an Identifier")
       


Output :



  Is not an Identifier

In the above code, we have declared a String '24A' which is not an Identifier.


x = "24A"

java_Collections

Now, to check, if the String is an Identifier, we have used 'isidentifier( )' function.


if x.isidentifier():
    print("Is an Identifier")
else:
    print("Is not an Identifier")

And in this case, '24A' is not an Identifier. So, we got the below output.


Is not an Identifier

Similarly, let us look at the next example.


Example :


x = "first_number"
if x.isidentifier():
    print("Is an Identifier")
else:
    print("Is not an Identifier")
       


Output :



  Is an Identifier

In the above code, we have declared a String 'first_number' which is an Identifier.


x = "first_number"

java_Collections

Now, to check, if the String is an Identifier, we have used 'isidentifier()' function.


    if x.isidentifier():
    print("Is an Identifier")
else:
    print("Is not an Identifier")

And in this case, 'first_number' is an Identifier. So, we got the below output.


Is an Identifier