Skip to content

Instantly share code, notes, and snippets.

@Maddix
Created September 30, 2015 00:21
Show Gist options
  • Select an option

  • Save Maddix/4177bc1c38b3b34e040f to your computer and use it in GitHub Desktop.

Select an option

Save Maddix/4177bc1c38b3b34e040f to your computer and use it in GitHub Desktop.
Python version of guess my number game. 17 lines long, though one could make it 15 lines long by removing the win variable and the user = int(user).
import random
num = random.randint(0, 100)
win = False
print("Guess my number game!")
while not win:
user = input("> ")
if user.isdecimal():
user = int(user)
if user > num:
print("To High!")
elif user == num:
print("Win!")
win = True
else:
print("To Low!")
else:
print("Numbers Only!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment