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(“,”)
for transaction in daily_transactions:
for transaction in daily_transactions_split:
for data_point in transaction:
transaction_clean.append(data_point.replace(“\n”, “”).strip(" "))
#for transaction in transactions_clean:
Thanks in advance
Please format your code so someone can help.
And, you might find a solution to this via the search . There are about 50+ posts on this project…and this very same issue.
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.
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.
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.