Is it possible to change the color of characters in a list if they do/dont meet certain conditions? So here's my code:
def checkWord(real, guess, remReal, remGuess, wrongSpot): # Format the letters so user knows whats wrong/right fullWord= real # Create copy list of real word realWord= list(fullWord) # Create index start point index= 0 # Iterate for each letter in 'guess' for letter in guess: #print(letter) # Print letter with '' if it is in the wrong positon list if letter in wrongSpot: print('[',letter,']',end='') # Convert letter in list to a '*' realWord[index]= '*' # Add to accumulator value index+=1 # Debug #print (realWord) # If the letter is one of the remaining letters in the guess list but # it's not in the current word list so it is not in the real word, # print only the letter elif letter in remGuess and letter not in realWord: print(letter,end='') realWord[index]= '*' index+=1 #print (realWord) # Print letter with '()' if letter is in the current word list elif letter in realWord: print('(',letter,')',end='') realWord[index]= '*' index+=1
I want the LIST characters to be changed to yellow if the first if condition is met, red and italic if the second elif condition is met, and green and bold if the last elif is met. Is there a way to go about doing this where the output prints into the shell?