Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6dffd4e commit c2bcf52Copy full SHA for c2bcf52
20-Hangman.py
@@ -0,0 +1,38 @@
1
+name = input("Name: ")
2
+print("Hello " + name + " time to play hangman!")
3
+
4
+secret_word = "Metallica"
5
6
+guesses = ""
7
8
+lives = 10
9
10
+while lives > 0:
11
12
+ character_left = 0
13
14
+ for character in secret_word:
15
16
+ if character in guesses:
17
18
+ print(character)
19
+ else:
20
+ print("-")
21
+ character_left += 1
22
23
+ if character_left == 0:
24
+ print("You won!!!")
25
+ break
26
27
28
+ guess = input("Guess a word: ")
29
+ guesses += guess
30
31
+ if guess not in secret_word:
32
+ lives -= 1
33
+ print("Wrong!")
34
+ print(f"You have {lives} left")
35
36
+ if lives == 0:
37
+ print("You died!")
38
0 commit comments