Skip to content

Instantly share code, notes, and snippets.

@JStoreInTheHills
Last active February 27, 2019 10:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JStoreInTheHills/f6005686621ac55a92769d1cac0b9c86 to your computer and use it in GitHub Desktop.
Save JStoreInTheHills/f6005686621ac55a92769d1cac0b9c86 to your computer and use it in GitHub Desktop.
simple guessing game in pyhton.
# Variables to store my secret and guess from user input.
secret_word = "giraffe"
guess = ""
# guesses flages.
guess_count = 0
guess_limit = 3
out_of_order = False
# Lopping through to check whether the user has entered correct secret word and he/she is not out of order.
while guess != secret_word and not out_of_order:
if guess_count < guess_limit:
guess = input("Enter your guess: ")
guess_count += 1
else:
out_of_order = True
if out_of_order:
print("Out of guesses, You Lose!")
else:
print("You Win!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment