-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dffd4e
commit c2bcf52
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name = input("Name: ") | ||
print("Hello " + name + " time to play hangman!") | ||
|
||
secret_word = "Metallica" | ||
|
||
guesses = "" | ||
|
||
lives = 10 | ||
|
||
while lives > 0: | ||
|
||
character_left = 0 | ||
|
||
for character in secret_word: | ||
|
||
if character in guesses: | ||
|
||
print(character) | ||
else: | ||
print("-") | ||
character_left += 1 | ||
|
||
if character_left == 0: | ||
print("You won!!!") | ||
break | ||
|
||
|
||
guess = input("Guess a word: ") | ||
guesses += guess | ||
|
||
if guess not in secret_word: | ||
lives -= 1 | ||
print("Wrong!") | ||
print(f"You have {lives} left") | ||
|
||
if lives == 0: | ||
print("You died!") | ||
|