- Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathguessinggame.py
27 lines (21 loc) · 656 Bytes
/
guessinggame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
importrandom
print("------------------------------")
print(" M&M guessing game!")
print("------------------------------")
print("Guess the number of M&Ms and you get lunch on the house!")
print()
mm_count=random.randint(1, 100)
attempt_limit=5
attempts=0
whileattempts<attempt_limit:
guess_text=input("How many M&Ms are in the jar? ")
guess=int(guess_text)
attempts+=1
ifmm_count==guess:
print(f"You got a free lunch! It was {guess}.")
break
elifguess<mm_count:
print("Sorry, that's too LOW!")
else:
print("That's too HIGH!")
print(f"Bye, you're done in {attempts}!")