Skip to content

Instantly share code, notes, and snippets.

@askingalot
Created February 15, 2022 20:56
Show Gist options
  • Save askingalot/4b98d96300d596093a10e523968e6610 to your computer and use it in GitHub Desktop.
Save askingalot/4b98d96300d596093a10e523968e6610 to your computer and use it in GitHub Desktop.
Python Input Validation
str_monkey_count = input("How many monkeys will fit in your living room? ")
while not str_monkey_count.isnumeric():
str_monkey_count = input("Please give me a number of monkeys! ")
monkey_count = int(str_monkey_count)
if monkey_count > 1:
print("I hope those monkeys get along")
elif monkey_count == 1:
print("Lonesome monkey :(")
else:
print("Why do you even have a living room if you don't keep monkeys in it?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment