Computer Science

Try to find out if for any case, the string functions isalnum( ) and isalpha( ) return the same result

Python String Manipulation

9 Likes

Answer

isalnum( ) and isalpha( ) return the same result in the following cases:

  1. If string contains only alphabets then both isalnum( ) and isalpha( ) return True. For example, "Hello".isalpha() and "Hello".isalnum() return True.
  2. If string contains only special characters and/or white-spaces then both isalnum( ) and isalpha( ) return False. For example, "*#".isalpha() and "*#".isalnum() return False.

Answered By

6 Likes


Related Questions