Skip to content

Instantly share code, notes, and snippets.

@eugene-eeo
Last active August 29, 2015 14:02
Show Gist options
  • Save eugene-eeo/31e3eaeb2cd42556a54f to your computer and use it in GitHub Desktop.
Save eugene-eeo/31e3eaeb2cd42556a54f to your computer and use it in GitHub Desktop.
Python number guessing
import random
number = random.randint(1, 1000)
prompt = "Guess a number: "
choice = -1
while choice != number:
choice = int(input(prompt))
if choice == number:
message ="Well done!"
elif choice < number:
message = "Number too low"
else:
message = "Number too high"
print(message)
prompt = "Try again: "
print("The number was "+str(number))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment