Thread Shed Project - My code outputs wrong numbers

Hi everyone,
I got stuck with Thread Shed Project : https://www.codecademy.com/courses/learn-python-3/projects/thread-shed
https://www.codecademy.com/workspaces/6348d931e5f0ddb2df1ef87e

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(“,”)
#print(daily_transactions)

daily_transactions_split =
for transaction in daily_transactions:
daily_transactions_split.append(transaction.split(“+”))

print(daily_transactions_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)

#print(transactions_clean)

customers =
sales =
thread_sold =

for transaction in transactions_clean:
customers.append(transaction[0])
sales.append(transaction[1])
thread_sold.append(transaction[2])

#print(customers)
print(sales)
#print(thread_sold)

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

print(thread_sold)

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 {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.

2 Likes

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.