I am building a small terminal game and there is a function gold_room
and it's the win for the game. There is a line of code that I have to ensure that a number is typed... But it's really long. Here is the function:
def gold_room():
print("This room is full of gold. How much do you take?")
choice = input("> ")
if "0" in choice or "1" in choice or "2" in choice or "3" in choice or "4" in choice or "5" in choice or "6" in choice or "7" in choice or "8" in choice or "9" in choice:
how_much = int(choice)
else:
dead("Man, learn to type a number.")
if how_much < 50:
print("Nice, you're not greedy, you win!")
exit(0)
else:
dead("You greedy bastard!")
I tried to use range()
but I kept getting errors. I'm new to Python and coding in general, so it's an experience for sure. Any help would be great!