-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman
45 lines (23 loc) · 795 Bytes
/
Hangman
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
secretword = "jerry"
lettersguessed = ""
wronglettercount = 0
maxmistakes = 5
while maxmistakes > 0:
guess = input("enter a letter: ")
if guess in secretword:
print (f" Right answer ,There are no or more {guess} in the secret word.")
else:
maxmistakes -= 1
print(f"Incorrect answer, There are no {guess} in the secret word.{maxmistakes} turn(s) left.")
lettersguessed = lettersguessed + guess
for letter in secretword:
if letter in lettersguessed:
print(f"{letter}", end="")
else:
print("_", end="")
wronglettercount += 1
if wronglettercount == 0:
print(f"u WON, the secret word was: {secretword}. you win")
break
else:
print("u LOST,wanna try again?")