I’m stuck in this assignment, in the first image you can see that when I print line 117 I have created a two dimensional list that needs to be cleaned from unnecessary extra spaces and “\n”.
Then after printing on line 124 I have successfully stripped those “ ” and “\n”, but I eliminated the 2D list.
I could only attach one picture but on line 125 you can see an example of what it prints.
help please…
From what you’re showing here, it looks like you’ve been mostly successful so far
because transactions_clean
is a list of strings where the whitespace has been trimmed already (using the .strip()
earlier.)
However, transactions_clean
should be a 2D list (meaning a list of lists of strings in this case).
You have
transactions_clean = []
for transaction in new_daily_sales:
for individual in transaction:
transactions_clean.append( individual.strip() )
but you should be appending lists of strings instead of strings.
transactions_clean = []
for transaction in new_daily_sales:
clean_list = [] # create list that will be added to transactions_clean
for individual in transaction:
clean_list.append( individual.strip() ) # adds stuff to inner list (in innermost loop)
transactions_clean.append(clean_list) # adds list to transactions_clean (in outer loop)
Also, next time please paste your code instead of using a screenshot
(using the </> button - put the code on lines between the ``` and ``` ).
2 Likes
Thank you so much for looking into it and my apologies for making it so hard to read with the screenshot. I’m getting used to this whole platform still. lol
I just adjusted it, and it ran perfectly. You guys are awesome!!