'How do I detect if a variable from the 1st list is equal to another variable in the 2nd list except for the nth variable in the other list?

Sorry if this sounds dumb but I have 2 lists, one is randomly generated and one is inputted by the user. How do I check if one variable inputted by the user is in the other list except for a specific variable in the other list?

if int(guessa_a) == int(a): print(Fore.GREEN + str(int(a)), end = "")
elif int(guessa_a) in randomlist: print(Fore.YELLOW + str(int(guessa_a)), end = "")
if int(guessa_a)not in randomlist: print(Fore.BLACK + str(int(guessa_a)), end = "")

Basically, I created a wordle remake with numbers, but if the user guesses a number twice, one in the correct spot and one in the incorrect spot, it will print both green and yellow numbers, when I want it to print only a green and a black number. So, how do I make it so that it detects if the variable is equal to a variable in another list, except for the nth variable in the list?



Solution 1:[1]

[...] a variable from the 1st list is equal to another variable in the 2nd list except for the nth variable in the other list?

I would suggest something like this:

del myList[n] # Removes the nth element, do it for all the lists

and then...

if (variable in myList and variable in mySecondList):
    ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FLAK-ZOSO