Answers for "check if correct identifier in python"

0

check if correct identifier in python

# Python program to identify the identifier 
  
# import re module 
  
# re module provides support 
# for regular expressions 
import re 
  
# Make a regular expression 
# for identify valid identifier 
regex = '^[A-Za-z_][A-Za-z0-9_]*'
      
# Define a function for 
# identifying valid identifier 
def check(string):  
  
     # pass the regualar expression 
     # and the string in search() method 
    if(re.search(regex, string)):  
        print("Valid Identifier")  
          
    else:  
        print("Invalid Identifier")  
      
  
# Driver Code  
if __name__ == '__main__' :  
      
    # Enter the string  
    string = input("Enter you Identifier\n")
    # calling run function  
    check(string)
Posted by: Guest on December-04-2020

Code answers related to "check if correct identifier in python"

Python Answers by Framework

Browse Popular Code Answers by Language