Can someone kindly explain why the following throws an exception? And what should I do with variable s to find out whether it contains a number?
s = str(10)
if s.isnumeric():
print s
When I read Python documentation it seems to me the above should work. See:
https://docs.python.org/3/library/stdtypes.html?highlight=isnumeric#str.isnumeric
But what I get is:
"AttributeError: 'str' object has no attribute 'isnumeric'"
Any help is most appreciated.
Thank you!
isdigit(), if that helps. It's not exactly the same, but it's available in Python 2.