Input:
["Red", "Blue", "Yellow", "Red", "Blue", "Green", "Red"]
Output
["Red":3, "Blue":2, "Yellow":1, "Green":1
The value is the amount of times the color popped up.
Input:
["Red", "Blue", "Yellow", "Red", "Blue", "Green", "Red"]
Output
["Red":3, "Blue":2, "Yellow":1, "Green":1
The value is the amount of times the color popped up.
my_list = ["Red", "Blue", "Yellow", "Red", "Blue", "Green", "Red"]
my_dict = {}
for i in my_list:
if i in my_dict:
my_dict[i] += 1
else:
my_dict[i] = 1