Thread shed p

I’m having an issue that is driving me mad.

aily_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)

this prints out in the console the same lists, but 4 times each and for the life of me i can’t understand why. I have even tried to copy the exast same lines of code from the video walkthrough and the same thing happens.
Could you please help with some pointes?

If the two append lines are in the same (inner) loop, then the same thing is being pushed multiple times. Be sure the append to transactions_clean is out dented so it is in the outer loop.

I managed to figure it out, 10 minutes after i posted it. Thank you very much for you help as well

1 Like