So I have done the assignment thankfully. But for the last task I think It could be better.

Now, using the list `colors` , the string method `.format()` , and the function `color_count` , iterate through `thread_sold_split` and print a sentence that says how many threads of each color were sold today.

My code:

``````colors = ['red','yellow','green','white','black','blue','purple']
def color_count(color):
count_red = 0
count_yellow = 0
count_green = 0
count_white = 0
count_black = 0
count_blue = 0
count_purple = 0
for x in range(len(color)):
if color[x] == 'red':
count_red += 1
elif color[x] == 'yellow:':
count_yellow += 1
elif color[x] == 'green':
count_green += 1
elif color[x] == 'white':
count_white += 1
elif color[x] == 'black':
count_black += 1
elif color[x] == 'blue':
count_blue += 1
elif color[x] == 'purple':
count_purple += 1

``````

I think that return thing can be made better. It turns out like this

``````('Thread sold 24 threads of  thread today.', 'Thread sold 0 threads of thread today.' ... ')
``````

``````Thread sold 24 threads of red thread today.
I believe the instructions for that task ask for a function which takes one argument, the `colour`, and returns the count for that specific `colour`.
Therefore you don’t need a single function to count each and every individual `colour`. You just call that single function whilst iterating through your list of `colours` in order to get the counts for each individual `colour` contained within that list. If you follow the instructions step by step it should naturally lead you to that solution.
If you’re interested in an alternative method, dictionaries and the `Counter` class would probably be the way to go but I’d avoid using them until they’re introduced in the lessons as you may trivialise tasks where you could still be learning important concepts. Where possible stick close to the instructions as many higher-level functions and classes aren’t introduced so as to get you to practice with the basic syntax of the language itself.