Skip to content

Instantly share code, notes, and snippets.

@mustafaaloko
Created February 11, 2024 17:01
Show Gist options
  • Save mustafaaloko/ffe0e6ed76c49eaac0a353f649ae0483 to your computer and use it in GitHub Desktop.
Save mustafaaloko/ffe0e6ed76c49eaac0a353f649ae0483 to your computer and use it in GitHub Desktop.
Python Number Guess Game
import random
random_number = random.randint(1, 20)
chance = 5
for i in range(1, 6):
guess_number = int(input("Take a guess (" + str(chance) + " chances): "))
if guess_number == random_number:
print("You Won!")
exit()
if guess_number < random_number:
print("You guessed too low")
chance = chance - 1
if guess_number > random_number:
print("You guessed too high")
print("You Lost!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment