Advertisement
# Signature of isidentifier() method
isidentifier()
# Python - Method isidentifier() Example
# Creating a string with a valid identifier
s1 = ('size')
# Printing the first string
print('Value of first string : ', s1)
# Calling the upper() method on first string
print('Calling the isidentifier()() method on first string : ', s1.isidentifier())
# Creating a string with a valid identifier
s2 = ('ink_price')
# Printing the second string
print('Value of second string : ', s2)
# Calling the isidentifier() method on second string
print('Calling the isidentifier()() method on second string : ', s2.isidentifier())
# Creating a string with an invalid identifier
s3 = ('1stprice')
# Printing the third string
print('Value of third string : ', s3)
# Calling the isidentifier() method on third string
print('Calling the isidentifier() method on third string : ', s3.isidentifier())
Value of first string : size
Calling the isidentifier() method on first string : True
Value of second string : ink_price
Calling the isidentifier() method on second string : True
Value of third string : 1stprice
Calling the isidentifier() method on third string : False
Advertisement
# Python - Method isidentifier() Example
# Calling isidentifier() on a string of characters and digits i.e. a valid identifier
print('apple_price2'.isidentifier())
# Calling isidentifier() on a string of all upper case letters i.e. a valid identifier
print('ACTOR'.isidentifier())
# Calling isidentifier() on a string of all lower case values separated by space i.e. an invalid indentifier
print('The name'.isidentifier())
# Calling isidentifier() on a string of all lower case letters separated by dot i.e. an invalid identifier
print('the.address'.isidentifier())
True
True
False
False
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement