The project for Strings in Python 3 course

I am having the issue with this project. After step 9, the output came out 4 lists for each like,
[‘Lucille Caldwell’, ‘$5.13’, ‘white’, ‘09/15/17’], [‘Lucille Caldwell’, ‘$5.13’, ‘white’, ‘09/15/17’], [‘Lucille Caldwell’, ‘$5.13’, ‘white’, ‘09/15/17’], [‘Eduardo George’, ‘$20.39’, ‘white&yellow’, ‘09/15/17’], [‘Eduardo George’, ‘$20.39’, ‘white&yellow’, ‘09/15/17’], [‘Eduardo George’, ‘$20.39’, ‘white&yellow’, ‘09/15/17’], [‘Eduardo George’, ‘$20.39’, ‘white&yellow’, ‘09/15/17’], I have no idea why this is happening. My codes are:

daily_sales_replaced = daily_sales.replace(’;,;’, ‘+’)
daily_transactions = daily_sales_replaced.split(’,’)
daily_transactions_split =
for transaction in daily_transactions:

transactions_clean =
for transaction in daily_transactions_split:

transaction_clean =
for data_point in transaction:
transaction_clean.append(data_point.replace("\n", “”).strip(" "))

Can anyone help me?

Hello @ocmikae, welcome to the forums! The variable transaction seems to have four elements in it, which which means that this loop:

repeats four times for every time time the outer loop iterates:


This comes up a lot and I suspect it has something to do with the video. Many, and I do mean, many learners don’t make the connection between the inner loop and the outer loop as each having their own running variable. The inner loop has transaction_clean and the outer loop has transactions_clean. When they both exist in the inner loop we get the multiple entry problem. The latter should be unindented to put it back in the outer loop.

@catower, is this something that could be put on a priority for revising the video? It has come up a tonne in these past years.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.