Zaktualizuj 'Projekt2/hangman.py'
This commit is contained in:
parent
8b4ceb9836
commit
fb0e297f87
@ -28,8 +28,7 @@ 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("Pudlo")
|
||||
print("-----------------------------")
|
||||
print("\n\033[1;36;40m Pudlo")
|
||||
return guessed_line
|
||||
|
||||
def user_input(input=input):
|
||||
@ -47,29 +46,27 @@ def n_main():
|
||||
guess_word_list = []
|
||||
while a:
|
||||
if guessed_line == s_word:
|
||||
print("\nGratulacje. Wygrales!")
|
||||
print("\n\033[1;33;40m Gratulacje. Wygrales!")
|
||||
break
|
||||
print("----------------------------------------")
|
||||
print("\nPozostalo prob: {}".format(tries))
|
||||
print("\n\033[1;31;40m Pozostalo prob: {}".format(tries))
|
||||
guess_word = user_input()
|
||||
if guess_word in guess_word_list:
|
||||
print("Podano wczesniej.")
|
||||
print("\n\033[1;31;40m Podano wczesniej.")
|
||||
continue
|
||||
if guess_word.isdigit():
|
||||
print("Cyfry sa niedozwolone!")
|
||||
print("\n\033[1;31;40m Cyfry sa niedozwolone!")
|
||||
continue
|
||||
if len(guess_word) != 1:
|
||||
print("\nDopusczalne tylko pojedyncze znaki.\n")
|
||||
print("\n\033[1;31;40m Dopusczalne 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("\n\033[1;32;40m Odgadles: {}".format(guess_word_list))
|
||||
print("========================================")
|
||||
tries = tries-1
|
||||
if (tries < 1):
|
||||
a= False
|
||||
print ("\n Nieodgadniete slowo: {} \n\n".format(s_word))
|
||||
print("\n\033[1;30;47m Nieodgadniete slowo: {} \n\n".format(s_word))
|
||||
|
||||
if __name__ == "__main__":
|
||||
n_main()
|
||||
|
Loading…
Reference in New Issue
Block a user