Resolved: why str(-11).isdigit() is false
I wanted to ask if I create a function and I want to make sure the argument passed to function is number.
How to do that ?
Also why does (-11).isdigit() returns False ?
Thanks for reaching out.
The problem is, when you put negative numbers such as -11, the isdigit() method counts the
- sign as a string value and it rejects it. So, we can slice it from the number. Please, use the following syntax:
Hope this helps.