isidentifier()

All String methods
my_str.isidentifier())
Returns True if the string is an identifier. Otherwise returns False.
Identifiers are names used to create objects, variables, functions, modules etc.

What is identifier ( Rules )

  1. Only lower or upper case chars , digits and underscore are allowed.
  2. We can't start identifier name with digit.
  3. $ , # , @, !, % ,special chars and space can't be used with identifiers
  4. We can't use reserved keywords as identifiers.
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


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    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-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer