Thread Shed

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

Hi everyone, for the Thread Shed project, I had a question about task #14. Here is the link to the project https://www.codecademy.com/courses/learn-python-3/projects/thread-shed

I get a total of 5994.9599999999955, which is different from 1498 shown in the YouTube solution. I have reviewed the code and everything looks the same as the video. Could it just be because the data for sales is different from the YouTube video? Or am I making a mistake. Any assistance on this would be greatly appreciated ! :blush:

It’s difficult to tell b/c you didn’t post any formatted code.

Please post your formatted code. Use the “</>” button above in the formatting options or refer to this post:

I’m having the same issue.
If you print out customers and sales you’ll the data being printed out multiple times instead of one which is what is throwing off the actual total from 1498 to 5994.9599999999955


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 transactions in transactions_clean:
  customers.append(transactions[0])
  sales.append(transactions[1])
  thread_sold.append(transactions[2])

#print(customers)
#print(sales)

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

#print(total_sales)

You need to fix this indentation. (You can also search here in the forums as this is a common mistake).

Why?

Summary

transaction_clean.append has to be indented and transactions_clean.append has to be at the outside level of the inner for loop, otherwise you’re cleaning, appending and then appending again, which would give you duplicates.