isidentifier()

All String methods
my_str.isidentifier())
Returns True if the string is an identifier. Otherwise returns False

What is identifier ( Rules )

  1. identifiers can contain chars ( both lower and upper case ), numbers and underscore.
  2. It can’t start with number
  3. It can’t contain space or any other special chars within it.
my_str='_abc45'
print(my_str.isidentifier()) # Output is True

my_str='ab#cd'
print(my_str.isidentifier()) # Output is False ( # not allowed )

my_str='A_abc1234'
print(my_str.isidentifier()) # Output is True

my_str='pq?rs'              
print(my_str.isidentifier()) # Output is False ( ? not allowed)

my_str='pq rs'              
print(my_str.isidentifier()) # Output is False ( space not allowed)

my_str='12ab'              
print(my_str.isidentifier())#Output is False( Can't start with number)


All String methods variables & identifiers in Python



plus2net.com



Post your comments , suggestion , error , requirements etc here





Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer