Permalink
Browse files

fizzbuzz

  • Loading branch information...
1 parent a225bf8 commit b2d2309614aa85bf6f81354a3dc266db7f780ac4 @kamzilla committed Jan 24, 2011
Showing with 33 additions and 0 deletions.
  1. +33 −0 fizzbuzz.py
View
@@ -0,0 +1,33 @@
+def get_input():
+ print "Enter in a number or 'exit' when done"
+ response = raw_input("> ")
+ input_check(response)
+
+def input_check(response):
+ if response.isdigit():
+ number = int(response)
+ fizz_buzz(number)
+ elif response.isalpha() and not response == "exit":
+ print "please enter a number, not a word"
+ get_input()
+ elif response == "exit":
+ print "thanks for playing"
+ return
+ else:
+ print "WTF!?!"
+ get_input()
+
+def fizz_buzz(number):
+ if number%3 == 0 and number%5 != 0:
+ print "fizz"
+ elif number%3 == 0 and number%5 == 0:
+ print "fizz buzz"
+ else:
+ print number
+ print "this number is not divisible by 3 and 5"
+ get_input()
+
+def run():
+ get_input()
+
+run()

0 comments on commit b2d2309

Please sign in to comment.