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:]
|
guessed_line = guessed_line [0:x] + guess_word + guessed_line[x+1:]
|
||||||
x = x+1
|
x = x+1
|
||||||
else:
|
else:
|
||||||
print("Pudlo")
|
print("\n\033[1;36;40m Pudlo")
|
||||||
print("-----------------------------")
|
|
||||||
return guessed_line
|
return guessed_line
|
||||||
|
|
||||||
def user_input(input=input):
|
def user_input(input=input):
|
||||||
@ -47,29 +46,27 @@ def n_main():
|
|||||||
guess_word_list = []
|
guess_word_list = []
|
||||||
while a:
|
while a:
|
||||||
if guessed_line == s_word:
|
if guessed_line == s_word:
|
||||||
print("\nGratulacje. Wygrales!")
|
print("\n\033[1;33;40m Gratulacje. Wygrales!")
|
||||||
break
|
break
|
||||||
print("----------------------------------------")
|
print("\n\033[1;31;40m Pozostalo prob: {}".format(tries))
|
||||||
print("\nPozostalo prob: {}".format(tries))
|
|
||||||
guess_word = user_input()
|
guess_word = user_input()
|
||||||
if guess_word in guess_word_list:
|
if guess_word in guess_word_list:
|
||||||
print("Podano wczesniej.")
|
print("\n\033[1;31;40m Podano wczesniej.")
|
||||||
continue
|
continue
|
||||||
if guess_word.isdigit():
|
if guess_word.isdigit():
|
||||||
print("Cyfry sa niedozwolone!")
|
print("\n\033[1;31;40m Cyfry sa niedozwolone!")
|
||||||
continue
|
continue
|
||||||
if len(guess_word) != 1:
|
if len(guess_word) != 1:
|
||||||
print("\nDopusczalne tylko pojedyncze znaki.\n")
|
print("\n\033[1;31;40m Dopusczalne tylko pojedyncze znaki.\n")
|
||||||
continue
|
continue
|
||||||
guess_word_list.append(guess_word)
|
guess_word_list.append(guess_word)
|
||||||
guessed_line = type_guess_word(s_word, guess_word,guessed_line)
|
guessed_line = type_guess_word(s_word, guess_word,guessed_line)
|
||||||
print (guessed_line)
|
print (guessed_line)
|
||||||
print("\n\033[1;32;40m Odgadles: {}".format(guess_word_list))
|
print("\n\033[1;32;40m Odgadles: {}".format(guess_word_list))
|
||||||
print("========================================")
|
|
||||||
tries = tries-1
|
tries = tries-1
|
||||||
if (tries < 1):
|
if (tries < 1):
|
||||||
a= False
|
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__":
|
if __name__ == "__main__":
|
||||||
n_main()
|
n_main()
|
||||||
|
Loading…
Reference in New Issue
Block a user