Python String isdigit() Method
You are Here:
Python String isdigit()
The isdigit()
method checks whether all the characters of the string are digits or not.
Note: Exponents, like 2, are also considered to be a digit.
Example
Python Compiler
str1 = "python"
str2 = "123"
str3 = "\u0031" # unicode for 1
str4 = "\u00B2" # unicode for ²
print(str1.isdigit()) # False
print(str2.isdigit()) # True
print(str3.isdigit()) # True
print(str4.isdigit()) # True
Output
False
True
True
True
Syntax
txt.isdigit()
Parameter Values
It does not take any parameter.
Return Value
Value | Explanation |
---|---|
True | If the characters of the string contains only digits. |
False | If the characters of the string contains other than digits. |
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on Python with examples for quick and easy learning.
We are working to cover every Single Concept in Python.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.