Python Thread Shed task 8 | When whitespace is stripped, only [...] is shown for lists

Hello,
Task 8 requires that I strip whitespace in a 2d list.
I was having issues where the printed list would contain […] as the nested lists.
After attempting to fix it and looking at the professionals video for the task, the lists still displayed […]
I copied the code from the reference video and the outcome was still the same.

daily_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.strip(" "))
    transactions_clean.append(transactions_clean)

print(transactions_clean)

Any help is appreciated.
Thank you in advance.

That line needs to be outdented so it is not in inner loop, but in the outer loop.

I outdented the line and the same is being output.

transactions_clean = []
for transaction in daily_transactions_split:
  transaction_clean = []
  for data_point in transaction:
    transaction_clean.append(data_point.strip(" "))
  transactions_clean.append(transactions_clean)

Does that look correct?

Thank you for your help.

1 Like