Python string | isalnum()
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:
- Python String Methods | Set 2 (len, count, center, ljust, rjust, isalpha, isalnum, isspace & join)
- Python | Check if given string can be formed by concatenating string elements of list
- String slicing in Python to check if a string can become empty by recursive deletion
- Python | Merge Tuple String List values to String
- Python | Sorting string using order defined by another string
- Python | Check if string ends with any string in given list
- Python | Check if a given string is binary string or not
- String slicing in Python to rotate a string
- Python | Sort each String in String list
- Python String | min()
- Python | Add one string to another
- Python String
- Python String | max()
- Python String | strip()
- string center() in python
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.


