Last active
February 27, 2019 10:37
-
-
Save JStoreInTheHills/f6005686621ac55a92769d1cac0b9c86 to your computer and use it in GitHub Desktop.
simple guessing game in pyhton.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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