Robotics & Artificial Intelligence

From the following, which function of Python checks whether all characters in a string 's' are alpha numeric?

  1. s.allnum()
  2. s.isnumal()
  3. s.isalnum()
  4. s.isalphanum()

Python String Manipulation

2 Likes

Answer

s.isalnum()

Reason — The function isalnum() is used to check whether all characters in a string are alphanumeric (i.e., letters and numbers). It returns True if all characters are either alphabets or digits, otherwise it returns False. The other options are incorrect because they are not valid Python string methods.

Answered By

1 Like


Related Questions