Skip to content

Instantly share code, notes, and snippets.

@Miqueas
Created April 6, 2021 16:44
Show Gist options
  • Save Miqueas/99b05a579cae8e43fd5156d420b66016 to your computer and use it in GitHub Desktop.
Save Miqueas/99b05a579cae8e43fd5156d420b66016 to your computer and use it in GitHub Desktop.
[Python] Classic guessing game
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