I have the following piece of code:
choice = raw_input("> ")
if "0" in choice or "1" in choice:
how_much = int(choice)
else:
dead("Man, learn to type a number.")
It seems like if "0" in choice or "1" in choice
is used to determine whether the raw input choice is an integer or not. Why is it? I was just a bit curious. Many thanks for your time and attention.
EDIT. It seems like a similar question already exists. See How to check if string input is a number?. Many thanks for the following different answers here. What I was curious is: why can we use if "0" in choice or "1" in choice to determine whether the raw input is a number or not in python.