This is incorrect:
Quote:since dictonaries won't update in an IF statement
Code in the body of an if statement is no different than code outside an if statement.
Looking at your code it looks like you are trying to make a mapping between colors and their location in colors1. Is the problem with dictionaries that they only map one value to each key? If so, you can use a list as the value of a dictionary. Like this:
from collections import defaultdict
colors1 = ['red', 'black', 'blue', 'green', 'red', 'black', 'blue', 'green', 'red', 'black', 'blue', 'green']
colors2 = defaultdict(list)
for index, color in enumerate(colors1):
colors2[color].append(index)
print(colors2)
Output:
defaultdict(<class 'list'>, {'red': [0, 4, 8], 'black': [1, 5, 9], 'blue': [2, 6, 10], 'green': [3, 7, 11]})
Quote:Is something Wrong with IDLE here ?
There are many things wrong with IDLE, but they probably don't affect if statements. Most problems you'll see running code in IDLE have to do with IDLE replacing some python functions with special IDLE versions. I've had trouble running code that moves the text cursor around or changes display fonts and colors. Tkinter programs run differently in IDLE. Pygame programs too. If you have doubts about IDLE affecting how your code runs, run it from the command line and see if it runs differently.
You should post your actual code. It is difficult to understand your questions about code when the code you post doesn't do anything.