Step 8 of thread shed project python 3!

Hi there ive tried for days now to solve why the computer is printing each list element multiple times.
Ive followed the tutorial video and copied the code exactly how the code is, in the tutorial video and it doesn’t work. It prints a totally different result than what is shown on the tutorial. i’ve tried dissecting the for loop and it just seems to have a mind of its own…
if it doesn’t print each element multiple times, it will print the list with many extra brackets or with no brackets… which doesnt look like how it should look in the tutorial video.
I would love to find the solution to this, my code is below:

daily_sales_replaced = daily_sales.replace(";,;", "+")

daily_transactions = daily_sales_replaced.split(",")

daily_transactions_split = []

for transaction in daily_transactions:

       daily_transactions_split.append(transaction.split("+"))

transactions_clean = []

for transaction in daily_transactions_split:

             transaction_clean = []

             for data_point in transaction:

                  transaction_clean.append(data_point.strip(" "))

                  transactions_clean.append(transaction_clean)

print(transactions_clean)

this prints:

[['Edith Mcbride', '$1.21', 'white', '\n09/15/17'], ['Edith Mcbride', '$1.21', 'white', '\n09/15/17'], ['Edith Mcbride', '$1.21', 'white', '\n09/15/17'], ['Edith Mcbride', '$1.21', 'white', '\n09/15/17'], ['Herbert Tran', '$7.29', '\nwhite&blue', '09/15/17']

etc…

i dont know how clear it is in the question but everything has been indented properly im sure of it as ive tried everything, the for loop starts at line: “for transaction in daily_transactions_split”
please help! thank you

Please post a link to this project’s landing page.

1 Like

My biggest suspicion is the indentation, particularly of the inner loop. This problem has been asked a lot and I’m not sure if it’s something about the video (from what I remember, it works fine in the video, but people often get one small thing wrong in this step).

F-strings are an incredibly useful tool to highlight the activities of your loops.
It’s usually very helpful when you put one at every operation for to just tally up what your variables are, and if they’re behaving as if they’re supposed to.

If they’re not, then you are very close to your answer.

You can also try finding other similar threads to this specific topic in the forum.

2 Likes

Thanks for your answers, I don’t see how there can be a solution to this as i’ve tried everything and also looked online at the similar questions posted before, on this particular step. nothing has made me solve it…

https://www.codecademy.com/courses/learn-python-3/projects/thread-shed

1 Like

if I don’t find the solution to this soon then I will just have to skip it without ever knowing why its doing this. tried everything…

Should both of those lines be in the same loop?

1 Like

they appear to be in the same loop in the tutorial video, I will see if putting them outside of the for loop helps

Just the last one. Leave the first inside the inner loop.

Thanks I will try it out

it throws constant syntax errors and eof errors when i do that but something is definitely up, because i cant notice any syntax errors where it says there is syntax errors…

thanks for your idea it might help with solving whats going on

Wow im pretty sure that fixed it, after indenting the transactions_clean.append(transaction_clean) to be within the first for loop but not the second one. the list looks exactly like how its supposed to!

Thank you for your help thats awesome!

1 Like

Take a look at this and see what you think, just my 2 cents: Making the most of video tutorials

thank you for the link you sent