the random choice does not seem to want to keep the same choice

Viewed 33

so I am trying to create a hangman game but, there is a problem whenever I run my code the random choice does not want to keep the same word it has chosen. for example, it might choose 'salad' first but then select a different word from the list when the code is still running and then compares it to the other word that it has chosen from the list. can someone tell me why it does that and give a solution on how I can fix it?

import random

lives = 10

def welcome(): 
 name = input("enter your name: ")
 print("hello " + name)
 print( name + " you will have this many(10) ")

def computer_role():
  list = ["person","salad","vehicle","piano","mood"]
  word = random.choice(list)
  return word

def game_correct():
 user = input("enter a letter: ")
 if user in computer_role():
    print(user)
    game_correct()
else:
    game_wrong()

def game_wrong():
for  user in computer_role():
        lives -1
        return lives
print("wrong word" + user + "this is how many lives you have left" + str(lives))
print("____/n"
    "l/n"
    "l/n"
    "l/n"
    "l/n"
    "l/n"
    "__l__")
    
        
 


 welcome()
 computer_role()
 game_correct()
 game_wrong()
0 Answers
Related