Q: Python Hangman, Difficulty selector not working properly I'm trying to make a hangman game that has 3 difficulty easy, medium and hard.
I'm facing a issue where my answer secretWord always return the value of "beautiful" in medium list regardless of what the user input. Can anyone help me see what is happening as I could not find the reason that this is happening.
import random

print("Welcome to Devil's Hangman")
#print("Lets Begin by choosing your difficulty for 'Easy', 'Medium' or 'Hard'.")

easy_list = ['trick','trout','youth','guess','gucci','treat']
medium_list = ['banker','traitor','monopoly','acoustic','beautiful','cafeteria']
hard_list = ['characteristics','sagittarius','personality','psychologist','photosynthesis','classification']



def printEmptyBlanks():
    for letter in secretWord:
        print("_", end=" ")
    
def hangmanGraphics(wrongCounter):
    if(wrongCounter == 0):
        print(' __________\n |\n |\n |\n |\n/_\ ')
        
    elif(wrongCounter == 1):
        print(' __________\n |       |\n |\n |\n |\n/_\ ')
        
    elif(wrongCounter == 2):
        print(' __________\n |       |\n |       O\n |\n |\n/_\ ')
        
    elif(wrongCounter == 3):
        print(' __________\n |       |\n |       O\n |       |\n |\n/_\ ')
        
    elif(wrongCounter == 4):
        print(' __________\n |       |\n |       O\n |      /|\n |\n/_\ ')
        
    elif(wrongCounter == 5):
        print(' __________\n |       |\n |       O\n |      /|\ \n |\n |\n/_\ ')
        
    elif(wrongCounter == 6):
        print(' __________\n |       |\n |       O\n |      /|\ \n |      /\n/_\ ')
        
    elif(wrongCounter == 7):
        print(' __________\n |       |\n |       O\n |      /|\ \n |      / \ \n/_\ ')
        
def previousInputs(lettersguessed):
    counter = 0
    rightLetters = 0
    for char in secretWord:
        if(char in lettersguessed):
            print(secretWord[counter], end=" ")
            rightLetters+=1
        else:
            print(" ", end=" ")
        counter+=1
    return rightLetters

def wordLines():
    print("\r")
    for char in secretWord:
        print("\u203E", end=" ")

#this is the part where my user input difficulty and my code supposed to generate a secretWord from my lists.

def difficultySelector():
    isValidInput=False
    while not isValidInput:
        userDifficulty = str(input("Lets Begin by choosing your difficulty for 'Easy', 'Medium' or 'Hard': ")).lower()
        if (userDifficulty == 'easy'):
            secretWord = random.choice(easy_list)
            isValidInput = True
            return secretWord
        elif (userDifficulty == 'medium'):
            isValidInput = True
            secretWord = random.choice(medium_list)
            return secretWord
        elif (userDifficulty == 'hard'):
            isValidInput = True
            secretWord = random.choice(hard_list)   
            return secretWord
        else:
            print("Invalid Entry.Please type only 'Easy', 'Medium' or 'Hard'")


difficultySelector()
hangmanGraphics(wrongCounter)
printEmptyBlanks()
secretWordLength = len(secretWord)
wrongCounter = 0
noOfGuesses = 0
lettersTried = []
correctLetters = 0
while(wrongCounter !=8 and correctLetters != secretWordLength):
    print("\nLetters guessed so far: ")
    for letter in lettersTried:
        print(letter, end=" ")
    userGuess = input("\nGuess a letter: ").lower()
    if(secretWord[noOfGuesses] == userGuess):
        hangmanGraphics(wrongCounter)
        noOfGuesses += 1
        lettersTried.append(userGuess)
        correctLetters = previousInputs(lettersTried)
        wordLines()
    else:
        wrongCounter += 1
        lettersTried.append(userGuess)
        hangmanGraphics(wrongCounter)
        correctLetters = previousInputs(lettersTried)
        wordLines()
print("\nGame is over!")

