Thread Shed Project - My code outputs wrong numbers

Hi everyone,
I got stuck with Thread Shed Project :

I followed the Walkthrough video step by step, but got completely different numbers:

  1. total_sales I got are 5994.9599999999955 while they should be 1498.740000000005
  2. color_count for different colors I got:
    Thread Shed sold 96 threads of red thread today. / should be 24
    Thread Shed sold 0 threads of yellow thread today. / should be 34
    Thread Shed sold 0 threads of green thread today. / should be 30
    Thread Shed sold 112 threads of white thread today. / should be 28
    Thread Shed sold 104 threads of black thread today. / should be 26
    Thread Shed sold 88 threads of blue thread today. / should be 22
    Thread Shed sold 68 threads of purple thread today. / should be 17

My code is:

Start coding below!

daily_sales_replaced = daily_sales.replace(“;,;”, “+”)
daily_transactions = daily_sales_replaced.split(“,”)

daily_transactions_split =
for transaction in daily_transactions:


transactions_clean =
for transaction in daily_transactions_split:
transaction_clean =
for data_point in transaction:
transaction_clean.append(data_point.replace(“\n”, “”).strip(" "))


customers =
sales =
thread_sold =

for transaction in transactions_clean:


total_sales = 0
for sale in sales:
total_sales += float(sale.strip(“$”))


thread_sold_split =
for sale in thread_sold:
for color in sale.split(“&”):

def color_count(color):
color_total = 0
for thread_color in thread_sold_split:
if color == thread_color:
color_total += 1
return color_total


colors = [‘red’, ’ yellow’, ’ green’, ‘white’, ‘black’, ‘blue’, ‘purple’]

for color in colors:
print(“Thread Shed sold {0} threads of {1} thread today.”.format(color_count(color), color))

I can’t understand why I arrived to these numbers. Please help!

Check whether that line is indented correctly.
It should be in the outer loop, but not in the inner loop.


Now it works :smiley: Thank you so much!!!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.