Skip to content

Instantly share code, notes, and snippets.

@bharris62
Created September 15, 2016 02:37
Show Gist options
  • Save bharris62/fecc43e14907e50a3035b4270bd9de97 to your computer and use it in GitHub Desktop.
Save bharris62/fecc43e14907e50a3035b4270bd9de97 to your computer and use it in GitHub Desktop.
# Fizz buzz, using input(). Added a while loop that will keep the user in the game until they supply a valid integer.
while True:
try:
n = int(input("Pick a number to be buzzed: "))
for i in range(1, n+1):
if i % 15 == 0:
print("FizzBuzz!")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
break
except:
print("that is not a valid integer, try again.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment