Thread Shed: why the duplicate strings?

Link to project

Hello all! I’m working on the Thread Shed project. Aside from the duplicate strings I’m seeing in the print output, everything’s been running fine. I’ve just finished populating the transactions_clean list, with all of the stripped data points. Following is the code I used to get to this point:

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.replace("\n", " ").strip(" "))
    transactions_clean.append(transaction_clean)

…and here is a sample of output for print(transactions_clean):

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

As you can see, each transaction is being repeated 4 times each. I’ve tried copying the code from the walkthrough video and am getting the same result.

If anyone could help me out in figuring out why this is occurring, I’d appreciate it!
Thanks for reading :slight_smile:

Too much indentation on that line. Likely the cause.

2 Likes

This appears to have solved the problem, and now I can carry on with the project. Thanks!

1 Like

Hey what exactly did you do to fix yours im running into the same problem regardless of indentation

I had the same problem. If over-indented, the output displayed 4-8 duplicates. If under-indented, the output displayed only one transaction (the last one I think).

However, I would like to understand why–and in what situations I could mess up my data with indents (since lists are mutable, correct?) however the list reverted to normal once I fixed the code, and it should be backed up by a tuple, right?