Created
August 15, 2018 15:58
-
-
Save LEvinson2504/c59fd08f4bec5f20792593ae498a0b70 to your computer and use it in GitHub Desktop.
A simple Guessing game
This file contains 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
#need to make it so that random words are imported, i couldnt get it to work | |
#words = requests.get("http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain").content.splitlines() | |
secret_word = "Levinson" | |
secret_word = secret_word.lower() | |
length = int(len(secret_word)) | |
hint = "" | |
hint_list = list() #strings are immutable | |
guess = "" | |
guess_count = 0 | |
guess_limit = len(secret_word)/2 | |
out_of_guesses = False | |
for i in range (length): | |
hint_list.append("_") | |
i += 1 | |
i = 0 #because for loop changes i | |
while guess != secret_word and not(out_of_guesses): | |
if guess_count < guess_limit: | |
print(hint_list) | |
guess = input("Enter guess :") | |
guess_count += 1 | |
hint_list[i] = secret_word[i] | |
i += 1 | |
else: | |
out_of_guesses = True | |
if out_of_guesses: | |
print("You loose :(") | |
else: | |
print("You Win!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment