Thread Shed: why the duplicate strings?


#1

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:


#2

Too much indentation on that line. Likely the cause.


#3

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