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