Permalink
Browse files

extra credit - fixed prompt for number in gold room to handle any num…

…ber, and retry if you enter a string
  • Loading branch information...
mwarkentin committed Jan 18, 2011
1 parent 1931145 commit daa63bde53691352c6eb66d5c17bed155f738e40
Showing with 7 additions and 6 deletions.
  1. +7 −6 ex35.py
View
13 ex35.py
@@ -6,12 +6,13 @@ def gold_room():
"""Describe gold room and take user input."""
print "This room is full of gold. How much do you take?"
next = raw_input(prompt)
if "0" in next or "1" in next:
how_much = int(next)
else:
dead("Man, learn to type a number.")
while True:
try:
next = raw_input(prompt)
how_much = int(next)
break
except ValueError:
print "That's not a number... try again!"
if how_much < 50:
print "Nice, you're not greedy, you win!"

0 comments on commit daa63bd

Please sign in to comment.