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:
- If string contains only alphabets then both isalnum( ) and isalpha( ) return True. For example, "Hello".isalpha() and "Hello".isalnum() return True.
- 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
What would the following expressions return?
- "Hello World".upper( ).lower( )
- "Hello World".lower( ).upper( )
- "Hello World".find("Wor", 1, 6)
- "Hello World".find("Wor")
- "Hello World".find("wor")
- "Hello World".isalpha( )
- "Hello World".isalnum( )
- "1234".isdigit( )
- "123FGH".isdigit( )
Which functions would you choose to use to remove leading and trailing white spaces from a given string?
Suggest appropriate functions for the following tasks:
- To check whether the string contains digits
- To find for the occurrence a string within another string
- To convert the first letter of a string to upper case
- to capitalize all the letters of the string
- to check whether all letters of the string are in capital letters
- to remove from right of a string all string-combinations from a given set of letters
- to remove all white spaces from the beginning of a string
In a string slice, the start and end values can be beyond limits. Why?