String Methods
str.isdecimal()
Identify nonempty text consisting entirely of Unicode decimal digits (category Nd). Persian digits and many other decimal digit sets pass. Signs, decimal points, separators and superscripts fail. This does not parse a complete numeric literal or ensure int() will accept arbitrarily long text under runtime conversion limits. Takes no arguments.
Formal Syntax & Structure
python syntaxpython
text.isdecimal()Return Value
bool
True when the stated classification holds; otherwise False.
Working Example
Example Snippetpython
quantity = "۴۲"print(quantity.isdecimal(), int(quantity))print("²".isdecimal())print("-42".isdecimal())