I just would need a way to be able to end my hangman man game through check if every letter the has entered is in the list.
What I was thinking was whenever I append the letter they type and if it is in the actual letter list I would remove it from the actual letter list until there are no more elements in the list and compare it in an if statement to when it zero, and the user would win the game.
Would this be the most effective way?
import random
Words = ["set", "scar", "cat"]
Letters_Guessed= ""
Guess = random.choice(Words)
ActualLetter = list(Guess) #use this to divide up the random word
print(ActualLetter)
Numb_guess = 0
max = 6
HANGER = [
'''
+---+
| |
|
|
|
|
=========
''',
'''
+---+
| |
O |
|
|
|
=========
''',
'''
+---+
| |
O |
| |
|
|
=========
''',
'''
+---+
| |
O |
/| |
|
|
=========
''',
'''
+---+
| |
O |
/|\ |
|
|
=========
''',
'''
+---+
| |
O |
/|\ |
\ |
|
=========
''',
'''
+---+
| |
O |
/|\ |
/ \ |
|
=========
''']
letterAmount = ""
for letter in Guess:
letterAmount += "_"
print(letterAmount)
game = True
def guess(UserguessL):
global Numb_guess, game, letterAmount, ActualLetter, Letters_Guessed, max
while game == True:
print(letterAmount)
if UserguessL in ActualLetter:
UserguessL = input("Good job! What another word? ")
Letters_Guessed += UserguessL
letterAmount = ""
print("Letters you have guessed: ", Letters_Guessed,)
elif UserguessL not in ActualLetter:
UserguessL = input("try again! ")
Letters_Guessed += UserguessL
Numb_guess += 1
print("Letters you have guessed: ", Letters_Guessed, )
print(HANGER[Numb_guess])
print(letterAmount)
if Numb_guess == max:
print("the word was", Guess)
game = False
UserguessL= input("Welcome to Hangman, player! In this game you must guess a word with letters, correctly within a limited amount of guesses. \n What is the first letter you like to guess? ")
guess(UserguessL)