Python Code Challenges - Strings challange - daily sales

Hello all,

I managed to get the right code after watching the help video. However, the list I am getting after print includes ‘6’ of the same transactions:
What Im I doing wrong?
How to only get 1 result per transaction?

question:
It looks like each data item has inconsistent whitespace around it. First, define an empty list transactions_clean .

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 transactions_clean .

synthax:

transactions_clean =

for transactions in daily_transactions_split:

transaction_clean =

for data_point in transactions:

transaction_clean.append(data_point.strip(""))

transactions_clean.append(transaction_clean)

print(transactions_clean)

result (not extensive, showing a few results for better understanding):

[’ Gail Phelps ', ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Gail Phelps ‘, ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Gail Phelps ‘, ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Gail Phelps ‘, ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Gail Phelps ‘, ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Gail Phelps ‘, ‘$30.52 \n’, ’ green&white&blue ‘, ’ 09’, ‘15’, ‘17 ‘], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’], [’ Myrtle Morris \n’, ’ $22.66 ‘, ’ green&white&blue’, ‘09’, ‘15’, ‘17’]]

Thanks for you help.
Ibrar

Hello @ruby9015221395. You are iterating through each of the objects in the nested lists within daily_transactions_split. Each of the lists nested within this list contain 6 items-that would be why you are getting six of the same list printed.
I hope this helps!

Hello,

I understand what you are saying.
Thanks for your input.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.