I have a question regarding Step 22 in the ‘Thread Shed’ project. I am able to print out the count of each color using .format(), but it prints everything for each color, leading to a lot of text in the console.
Can someone point me in the right direction for just printing each color once?
I’ve tried setting count variables, if statements, nested for loops…They all come out the same.
Here is my current code for this step:
for color in thread_sold_split:
if color in colors:
print("Thread Shed sold {} threads of {} thread today.".format(color_count(color), color))
Nevermind! I managed to figure it out after all…while loops are very handy indeed
Here is the code I used in case anyone needs a push in the right direction:
colors = ['red','yellow','green','white','black','blue','purple']
counter = 0
while counter < len(colors):
for color in colors:
if color in colors:
print("Thread Shed sold {} threads of {} thread today.".format(color_count(color), color))
counter += 1