From 78d7f05c282dd5afe6ec3ab795925f67fee869d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Korbanek?= Date: Fri, 8 Mar 2019 21:15:57 +0000 Subject: [PATCH] Zaktualizuj 'Projekt2/hangman.py' --- Projekt2/hangman.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Projekt2/hangman.py b/Projekt2/hangman.py index 8d876c0..4d11c51 100644 --- a/Projekt2/hangman.py +++ b/Projekt2/hangman.py @@ -7,11 +7,11 @@ def get_secret_word(word_file="/usr/share/dict/words"): good_words = [] for i in f: i = i.strip() - if len(i) <= 6: # No short words + if len(i) <= 6: continue - if not i.isalpha(): # No punctuation + if not i.isalpha(): continue - if i[0].isupper(): # No proper nouns + if i[0].isupper(): continue good_words.append(i) return random.choice(good_words) @@ -28,19 +28,18 @@ def type_guess_word(word_file, guess_word, guessed_line): guessed_line = guessed_line [0:x] + guess_word + guessed_line[x+1:] x = x+1 else: - print("Wrong guess") + print("Pudlo") print("-----------------------------") return guessed_line def user_input(input=input): - letter = input("enter the chacracter=") + letter = input("Podaje litere:") return letter def n_main(): print ("Welcome.") s_word =(get_secret_word()) - #print(s_word) guessed_line=(get_masked_word(s_word)) print(get_masked_word(s_word)) a =True @@ -48,29 +47,29 @@ def n_main(): guess_word_list = [] while a: if guessed_line == s_word: - print("\n\U0001F44D\U0001F44D\U0001F44D CONGRATULATION ..!! YOU WON THE GAME") + print("\nGratulacje. Wygrales!") break print("----------------------------------------") - print("\nTries left = {}".format(tries)) + print("\nPozostalo prob = {}".format(tries)) guess_word = user_input() if guess_word in guess_word_list: - print("already guess") + print("Podano wczesniej") continue if guess_word.isdigit(): - print("digits not allowed") + print("Cyfry sa niedozwolone") continue if len(guess_word) != 1: - print("\n single char only...!!!\n") + print("\nDopusczalne tylko pojedyncze znaki\n") continue guess_word_list.append(guess_word) guessed_line = type_guess_word(s_word, guess_word,guessed_line) print (guessed_line) - print ("already guessed word ={}".format(guess_word_list)) + print ("Odgadles ={}".format(guess_word_list)) print("========================================") tries = tries-1 if (tries < 1): a= False - print ("\n So tries left sorry..the secret word is {} \U0001F622 \U0001F622\n\n".format(s_word)) + print ("\n Nieodgadniete slowo: {} \n\n".format(s_word)) if __name__ == "__main__": n_main()