In your second function you apply any to a single element and not to the whole list. Thus, you get a single bool element if character i is alphanumeric.

In the second case you cannot really use any as you work with single elements. Instead you could write:

for i in s:
    if i.isalnum():
        print(True)
        break

Which will be more similar to your first case.

Answer from JohanL on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_string_isalnum.asp
Python String isalnum() Method
Python Examples Python Compiler ... Python Certificate Python Training ... The isalnum() method returns True if all the characters are alphanumeric, meaning alphabet letter (a-z) and numbers (0-9)....
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
February 25, 2026 - str.isalnum()¶ · Return True if all characters in the string are alphanumeric and there is at least one character, False otherwise. A character c is alphanumeric if one of the following returns True: c.isalpha(), c.isdecimal(), c.isdigit(), ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-isalnum-method
Python String isalnum() Method - GeeksforGeeks
April 21, 2025 - The isalnum() method is a string function in Python that checks if all characters in the given string are alphanumeric. If every character is either a letter or a number, isalnum() returns True.
🌐
Programiz
programiz.com › python-programming › methods › string › isalnum
Python String isalnum() (With Examples)
Become a certified Python programmer. Try Programiz PRO! ... The isalnum() method returns True if all characters in the string are alphanumeric (either alphabets or numbers).
🌐
Codecademy
codecademy.com › docs › python › strings › .isalnum()
Python | Strings | .isalnum() | Codecademy
July 15, 2025 - The .isalnum() method is a built-in string method in Python that checks whether all characters in a string are alphanumeric. This method returns True if every character in the string is either a letter (a-z, A-Z) or a digit (0-9), and the string ...
🌐
Dot Net Perls
dotnetperls.com › isalnum-python
Python - String isalnum Example - Dot Net Perls
October 9, 2021 - Sometimes we want to ensure a Python string has no punctuation or other whitespace. We can see if it contains just letters and digits. With isalnum, we have a method that loops over the characters in the string.
Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.isalnum.html
pandas.Series.str.isalnum — pandas 3.0.2 documentation
>>> s1 = pd.Series(["one", "one1", "1", ""]) >>> s1.str.isalnum() 0 True 1 True 2 True 3 False dtype: bool
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-string-isalnum
Python String isalnum() | DigitalOcean
August 3, 2022 - Python string isalnum() function returns True if it’s made of alphanumeric characters only. A character is alphanumeric if it’s either an alpha or a number.
🌐
Cach3
w3schools.com.cach3.com › python › ref_string_isalnum.asp.html
Python String isalnum() Method
Python Examples Python Exercises Python Quiz Python Certificate ... The isalnum() method returns True if all the characters are alphanumeric, meaning alphabet letter (a-z) and numbers (0-9).
🌐
Initial Commit
initialcommit.com › blog › python-isalpha-string-method
Python isAlpha, isAlnum, isDigit, isDecimal, isNumeric, & Other String Methods
November 2, 2021 - Again, strings for negative numbers due to the inclusion of the minus sign operator are not considered numeric in Python: ... >>> "abcdefg".isalnum() # letters: isalpha True >>> "12345".isalnum() # numbers: isdecimal True >>> "\u00B2".isalnum() # superscript 2: isdigit True >>> "\u2168".isalnum() # roman numeral 9: isnumeric True
🌐
Tutorialspoint
tutorialspoint.com › python › string_isalnum.htm
Python String isalnum() Method
The python string isalnum() method is used to check whether the string consists of alphanumeric characters. This method returns true if all the characters in the input string are alphanumeric and there is at least one character.
🌐
Vultr Docs
docs.vultr.com › python › standard-library › str › isalnum
Python str isalnum() - Check Alphanumeric Characters | Vultr Docs
November 26, 2024 - The isalnum() method in Python strings is a straightforward tool for validating whether the content of a string consists exclusively of alphanumeric characters (letters and numbers).
🌐
Accuweb
accuweb.cloud › home › python string isalnum() with examples
Python String isalnum() With Examples - AccuWeb Cloud
January 1, 2024 - The Python ‘string.isalnum()’ function says ‘True’ if the text has only letters and numbers.
🌐
CS50
manual.cs50.io
CS50 Manual Pages
isalnum - character classification functions check whether a character is alphanumeric · isalnum_l - character classification functions · isalpha - character classification functions check whether a character is alphabetical · isalpha_l - character classification functions ·
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › str › isalnum.html
isalnum — Python Reference (The Right Way) 0.1 documentation
isalnum · Edit on GitHub · Returns a Boolean stating whether the string contains only letters and digits. str. isalnum() bool · #TODO · For 8-bit strings, this method is locale-dependent. Returns False if string is empty.
🌐
Oreate AI
oreateai.com › blog › understanding-pythons-isalnum-method-a-deep-dive-into-alphanumeric-strings › 9c033e07348b7509b8e476a3bdcfeb87
Understanding Python's Isalnum() Method: A Deep Dive Into Alphanumeric Strings - Oreate AI Blog
December 31, 2025 - The isalnum() method checks if all characters in a string are alphanumeric (i.e., either letters or digits) and returns True if they are; otherwise, it returns False.
🌐
PyPI
pypi.org › project › python-dotenv
python-dotenv · PyPI
In auto mode, don't add quotes if the value is only made of alphanumeric characters (as determined by string.isalnum). ... Fixed tests for build environments relying on PYTHONPATH (#318 by @befeleme).
      » pip install python-dotenv
    
Published   Mar 01, 2026
Version   1.2.2
🌐
Studytonight
studytonight.com › post › python-string-methods-isalpha-isalnum-and-isascii
Python String methods - isalpha(), isalnum() and isascii() - Studytonight
September 13, 2021 - The isalnum method can be called as an extension of the isalpha python method. In addition to checking for the presence of alphabets in the string, the isalnum method checks whether the method contains numeric characters too.