my code needs some tweaking as Im not getting the result I need to continue with my Task called Thread Shed in Learn: Python Strings. This issue has been addressed before, but the proper solution is not clear to me. Previous solution
There are instructions in the Task which instrucs me to do this:
It looks like each data item has inconsistent whitespace around it. First, define an empty list
Now, Iterate through
daily_transactions_split and for each transaction iterate through the different data points and strip off any whitespace.
Add each of these cleaned up transactions to the new list
Problem with my code below(the first part of code) that it does not work the way I was hoping to. No Indentation error. Nothing. It just displays the same result like “daily_transactions_split”. Like there was no operation.
The second attempt (the code under the first code) does the job of removing whitespace, but also destroys the transaction list in the process and all the elements appear in one big list and I cannot therefore finish this excercise.
Pls be so kind and offer the comprehensive solution. Im sure it´s simple I just cant seem to see it for the last 4 hours.
daily_sales_replaced = daily_sales.replace(";,;","--") daily_transactions = daily_sales_replaced.split(",") daily_transactions_split =  for transaction in daily_transactions: transcation_splitted = transaction.split("--") daily_transactions_split.append(transcation_splitted) transactions_clean =  for transaction in daily_transactions_split: for element in transaction: element.strip() transactions_clean.append(transaction) print(transactions_clean)
transactions_clean =  for transaction in daily_transactions_split: for element in transaction: transactions_clean.append(element.strip())