Skip to content

Instantly share code, notes, and snippets.

@bolenton
Created November 30, 2015 05:06
Show Gist options
  • Save bolenton/3b06178b4007b946a858 to your computer and use it in GitHub Desktop.
Save bolenton/3b06178b4007b946a858 to your computer and use it in GitHub Desktop.
random number game.py
from random import randint
print(" Hey lets play a game!")
print("\n I'm' thinking of a number between 1 and 20.")
print('\n You have 5 turns to guess my number or you lose.')
raw_input("\n Press RETURN when you're ready go play .")
test = 0
num = randint(1, 20)
while test <= 4:
guess = int(raw_input("\n What do you think the number is? \n >>>"))
if guess == num:
print("\n *" * 10)
print("\n Wow! You Got it right.")
print("\n You Win!")
break
elif guess > num:
print("\n Sorry, but thats too high.")
elif guess < num:
print("\n That number is too low.")
elif guess < 20:
print("I said between 1 and 20 you dummy.")
else:
break
test += 1
print("\n Thats was turn number {}").format(test)
if test == 5:
print("\n *" * 10)
print("\n\n\n YOU LOSE")
else:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment