isalnum() function in Python programming language checks whether all the characters in a given string is alphanumeric or not.
Alphanumeric:A character that is either a letter or a number
Syntax:
string_name.isalnum()
string_name is the name of the string
Parameter: isalnum() method takes no parameters
Return:
True: If all the characters are alphanumeric
False: If one or more characters are not alphanumeric
Below is the Python implementation of the isalnum() method
# Python program to demonstrate the use of # isalnum() method # here a,b and c are characters and 1,2 and 3 # are numbers string = "abc123"print(string.isalnum()) # here a,b and c are characters and 1,2 and 3 # are numbers but space is not a alphanumeric # character string = "abc 123" print(string.isalnum()) |
Output:
True False
Recommended Posts:
- String slicing in Python to check if a string can become empty by recursive deletion
- String slicing in Python to rotate a string
- String Alignment in Python f-string
- Pad or fill a string by a variable in Python using f-string
- Python | String startswith()
- Python string | strip()
- Python program to split and join a string
- Python String isspace() and its application
- Python String index() and its applications
- Python String isalpha() and its application
- Python code to move spaces to front of string in single traversal
- Python String isdigit() and its application
- Python Regex to extract maximum numeric value from a string
- Find the first repeated word in a string in Python using Dictionary
- Concatenated string with uncommon characters in Python
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Python | Swap commas and dots in a String
- Python | Program to convert String to a List
- Python | Count and display vowels in a string
- Python | Check for URL in a String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

