Search code examples
pythonpython-3.xstringnumbersdigits

How can a Python string be a digit?


I was under the impression that numbers in double-quotation marks become strings. Why did I get the following result?

"2001".isdigit()
True

Solution

  • It says .isdigit() not .isint() which makes sense since int and string are Python types, but nobody says a string can't be digits.

    In fact, strings can contain letters, alphanumeric, digits, and a bunch of other things.