Skip to content
Browse files

Merge pull request #2 from NattyBumppo/master

Recursion/memory-related fix
  • Loading branch information...
2 parents 00f9adf + 1d9ec7c commit da5cb5343d8fc05e62ecdea6fb3a90035ac94844 @kamzilla committed Mar 13, 2012
Showing with 9 additions and 7 deletions.
  1. +9 −7 fizzbuzz.py
View
16 fizzbuzz.py
@@ -1,21 +1,22 @@
def get_input():
print "Enter in a number or 'exit' when done"
response = raw_input("> ")
- input_check(response)
+ return response
def input_check(response):
if response.isdigit():
number = int(response)
fizz_buzz(number)
+ return False
elif response.isalpha() and not response == "exit":
print "please enter a number, not a word"
- get_input()
+ return False
elif response == "exit":
print "thanks for playing"
- return
+ return True
else:
print "WTF!?!"
- get_input()
+ return False
def fizz_buzz(number):
if number % 15 == 0:
@@ -26,10 +27,11 @@ def fizz_buzz(number):
print "buzz"
else:
print number
- print "this number is not divisible by 3 and 5"
- get_input()
+ print "this number is not divisible by 3 and 5"
def run():
- get_input()
+ ready_to_exit = False
+ while (not ready_to_exit):
+ ready_to_exit = input_check(get_input())
run()

0 comments on commit da5cb53

Please sign in to comment.
Something went wrong with that request. Please try again.