-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHangmanAS05
More file actions
29 lines (29 loc) · 851 Bytes
/
HangmanAS05
File metadata and controls
29 lines (29 loc) · 851 Bytes
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
import random
wordlist=["pack","buy","sector","dealer","trap","equip","shop","black","back","urgency","charity","method","fork","thirsty"]
wordchoice=random.choice(wordlist)
wrongguesses=6
lettersguessed=[0]
board=[]
for x in range(len(wordchoice)):
board.append("_")
print("".join(board))
print(f"{wrongguesses} guesses left")
while wrongguesses!=0:
letter=0
while letter in lettersguessed:
letter=(input("Input letter:"))
if letter in lettersguessed:
print("Letter already guessed")
if letter not in wordchoice:
wrongguesses=wrongguesses-1
print(f"{wrongguesses} guesses left")
for x in range(len(wordchoice)):
if letter==wordchoice[x]:
board[x]=letter
lettersguessed.append(letter)
print("".join(board))
if "_" not in board:
print("Congrats")
break
if "_" in board:
print("Out of guesses")