import random
pics = ["""
+---+
| |
|
|
|
|
=========""","""
+---+
| |
O |
|
|
|
=========""","""
+---+
| |
O |
| |
|
|
=========""","""
+---+
| |
O |
/| |
|
|
=========""","""
+---+
| |
O |
/|\ |
|
|
=========""","""
+---+
| |
O |
/|\ |
/ |
|
=========""","""
+---+
| |
O |
/|\ |
/ \ |
|
========="""]
while True:
print(("-" * 30) + "\nHangman Game\n" + ("-" * 30))
word = random.choice(["java", "python", "html", "ruby", "javascript", "css"])
step = 0
letters = []
while True:
print(pics[step])
for i, char in enumerate(word):
print(char if i in letters else "_"),
answer = input("\nAnswer: ")
if answer == word:
print("You win!\n\n")
break
else:
while True:
rand = random.randint(0, len(word))
if not rand in letters:
letters.append(rand)
break
step += 1
if step >= len(pics):
print("You lose!\n\n")
break
if not "y" == input("Play again (y/n): "):
break
bu kodu yazıp cmd ile çalıştırabilirsiniz ve sözlük kısmına kendi kelimelerinizi ekleyip arkadaşlarınızla oynayabilirsiniz.
(BURDA SORU SORMADIM, SADECE EĞLENCELİ BİR BİLGİ VERDİM)