Created
April 6, 2021 16:44
-
-
Save Miqueas/99b05a579cae8e43fd5156d420b66016 to your computer and use it in GitHub Desktop.
[Python] Classic guessing game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint as rand | |
MagicNum = rand(1, 100) | |
Lives = 3 | |
print("Guess the number!") | |
print("Enter your choice:") | |
choice = int(input("> ")) | |
while True: | |
if choice != MagicNum and Lives != 0: | |
print("Bad! Try again:") | |
choice = int(input("> ")) | |
Lives -= 1 | |
elif choice != MagicNum and Lives == 0: | |
print("You loss!") | |
print(f"The number is {MagicNum}") | |
break | |
else: | |
print("You win!") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment