Thread Shed Project

Hey guys, I have an issue I need help with the Thread Shed project. Basically, my code is printing out every piece of data three times when I print out. I have narrowed it down to the last print statement you see that isn’t commented out (print(transactions_clean). It has to be in the for loops right above it but for some reason I can’t see it, so any help would be much appreciated.

Here is a link to the project:

Python: Strings | Codecademy

Here is my code:

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)

Thanks in advance

Please format your code so someone can help.
See:
https://discuss.codecademy.com/t/how-do-i-format-code-in-my-posts/28351/5

And,
https://discuss.codecademy.com/guidelines#improve

And, you might find a solution to this via the search :mag:. There are about 50+ posts on this project…and this very same issue.
See:
https://discuss.codecademy.com/search?q=thread%20shed

1 Like

Thanks, I will look into that

I see my issue now; it was an indentation error on the second append statement on my second for loop in the transaction_clean block of code. I tried to go back and edit my original post to post the code correctly but apparently, I am missing that shortcut to add code for some reason. I wanted to fix it so maybe you could explain to me exactly why the indentation error was causing the issue. I understand why it worked, but from looking at the data I am confused why it was printing three items instead of four.

1 Like

One is not able to edit posts after a certain time period has elapsed which is probably why you couldn’t format your previous post.

If you post your formatted code now using this button: </>
then we can read it better and help break it down.

1 Like

Thanks again for the response, but I still don’t have the </> buttons in my shortcuts. I just tried replying to your message and was going to add it. I am not sure why I don’t have it.

1 Like