adrianwii

Untitled

May 11th, 2025
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. from hangman_states import *
  2. import random
  3.  
  4. def losuj_slowo():
  5.     words = ["samochod", "tree", "vegetables", "monopoly", "Katowice"]
  6.     return random.choice(words)
  7.  
  8. word = losuj_slowo()
  9. guess_word = ["_"] * len(word)
  10. guessed_letters = []
  11. state = 1
  12.  
  13. print(word)
  14.  
  15. print(f"Witaj w Hangmanie! Twoim zadaniem jest zgadnąć słowo!")
  16. print(" ".join(guess_word))
  17.  
  18. for l in word:
  19.     l = l.lower()
  20.  
  21. while "_" in guess_word:
  22.     if state == 7:
  23.         print("Przegrałeś")
  24.         break
  25.  
  26.     letter = input("Podaj literke").lower()
  27.  
  28.     if letter not in word:
  29.         state+=1
  30.         guessed_letters.append(letter)
  31.         print("🔴 Zła litera!")
  32.     else:
  33.         for index, l in enumerate(word):
  34.             if letter == l.lower():
  35.                 guess_word[index] = letter
  36.         print("✅ Dobrze, trafiłeś")
  37.  
  38.     print(HANGMAN_STATES[-1*state])
  39.     print(" ".join(guess_word))
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment