Which of the following functions cannot be used with string(str) data type?
2023
Which of the following functions cannot be used with string(str) data type?
- A.
islower( )
- B.
isupper( )
- C.
isalpha( )
- D.
isnum( )
Attempted by 1898 students.
Show answer & explanation
Correct answer: D
The function isnum() does not exist for Python strings. Python provides several methods to check numeric content, such as isdigit(), isdecimal(), and isnumeric().
isdecimal() checks for decimal digits (0–9) only. isdigit() includes digit characters, including some Unicode digits. isnumeric() is broader and includes numeric characters like fractions, superscripts, and other Unicode numerals.
For example, '123'.isdecimal() returns True, while 'Ⅻ'.isnumeric() returns True. However, isnum() is not a valid method and cannot be used.