Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions practices/ch06-organizing-code-with-functions/guessinggame.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
attempts = 0

while attempts < attempt_limit:
guess_text = input("How many M&Ms are in the jar? ")
guess = int(guess_text)
attempts += 1
try:
guess_text = input("How many M&Ms are in the jar? ")
guess = int(guess_text)
attempts += 1

if mm_count == guess:
print(f"You got a free lunch! It was {guess}.")
break
elif guess < mm_count:
print("Sorry, that's too LOW!")
else:
print("That's too HIGH!")
if mm_count == guess:
print(f"You got a free lunch! It was {guess}.")
break
elif guess < mm_count:
print("Sorry, that's too LOW!")
else:
print("That's too HIGH!")

print(f"Bye, you're done in {attempts}!")
print(f"Bye, you're done in {attempts}!")
except:
print("Enter an integer Value !")