LEARN PYTHON 3 Thread Shed proyect

In step 8 of this project, the internal lists (the one that shows the 4 chains of each transaction) are repeated 4 times each and I don’t know why! I got stuck until I realized that this problem would not let me advance and even placing the same developer code to discover the failure, they are repeated anyway.
Help pls!

transactions_clean =

for transaction in daily_transactions_split:

transaction_clean =

for data in transaction:

transaction_clean.append(data.strip())

transactions_clean.append(transaction_clean)

print(transactions_clean)

My code: My code: https://gist.github.com/fdccf2db1cd46294d72c09273db7533b

Hi,

Welcome to the forum! Use the </> button before pasting your code so that it’s formatted properly, it really counts with helping users help you!

The way you wrote your loop:

transactions_clean = []
for transaction in daily_transactions_split:
  #Part A
  transaction_clean = []
  for data in transaction:
    #Part B // any code

You are going to have transactions_clean being set to [] every time you loop through your list. So whatever code affects transactions_clean in the nested loop is going to be rendered obsolete (except for the very last loop).

1 Like