Thread shed task 8

daily_sales_replaced = daily_sales.replace(';,;', '+') daily_transactions = daily_sales_replaced.split(',') daily_transactions_split = [] for transaction in daily_transactions: daily_transactions_split.append(transaction.split('+')) transactions_clean = [] for transaction in daily_transactions_split: transaction_clean = [] for data_point in transaction: transaction_clean.append(data_point.replace('\n', '').strip(' ')) transactions_clean.append(transaction_clean) customers = [] sales = [] thread_sold = [] for transaction in transactions_clean: customers.append(transaction[0]) sales.append(transaction[1]) thread_sold.append(transaction[2]) total_sales = 0 for sale in sales: total_sales += float(sale.strip('$')) #print(total_sales) thread_sold_split = [] for sale in thread_sold: for color in sale.split("&"): thread_sold_split.append(color) def color_count(color): color_total = 0 for thread_color in thread_sold_split: if color == thread_color: color_total += 1 return color_total print(color_count('white')) colors = ['red','yellow','green','white','black','blue','purple'] for color in colors: print("Thread Shed sold {} threads of {} thread today.".format(color_count(color), color))

Why do I get 112 colors of white???

As far as I can tell, the nested for-loop you have here is “multiplying” all your stuff by 4:

for transaction in daily_transactions_split: 
  transaction_clean = []
  for data_point in transaction:
   transaction_clean.append(data_point.replace('\n', '').strip(' '))
   transactions_clean.append(transaction_clean)

I think that last line above should not be in the inner for-loop.

link to Thread Shed project: https://www.codecademy.com/courses/learn-python-3/projects/thread-shed