is digit() python:
- The isdigit() in python is defined as the string that consists of only digit values.
- It returns the result in boolean type if the string has only digits it returns true else false.
- It accepts the Unicode of that characters also. and also the exponents like ^2.
- It is not applicable to whitespace, special symbols, alphabets.
Example: str="123456"
str.isdigit(str) retrns true
Beacuse "123456" is perfectly a digit.
str=\u00B0
str.isdigit(str)returns true
Because it takes the Unicode as digit characters.
#write a python code to demonstrate isdigit() function.
- a="7656734"
- a=str.isdigit(a)
- print(a)
- b="2344.60
- b=str.isdigit(b)
- print(b)
- x="\u00B2"
- x=str.isdiigt(x)
- print(x)
output: true
false
true
No comments