Thread Shed Challenge

exercise link:

transactions_clean = []
for tr in daily_transactions_split:
  for space in range(len(tr)):
    tr[space] = tr[space].strip()

customers = []
sales = []
thread_sold = []

for trans in transactions_clean:
  if trans[0] in trans:
    name = trans[0]
for sale in transactions_clean:
  if sale[1] in sale:
    price = sale[1]

for thread in transactions_clean:
  if thread[2] in thread:
    thread_type = thread[2]

When I print my individual lists to the console, the individual lists print out a list of each name, sale, and thread four times in what seems like an almost never ending repetition of the individual lists.

['white', 'white', 'white', 'white', 'white&blue', 'white&blue', 
'white&blue', 'white&blue', 'white&blue', 'white&blue', 'white&blue',
 'white&blue', 'white', 'white', 'white', 'white', 'white&yellow',
 'white&yellow', 'white&yellow', .....]```

Not sure if this is caused by the previous transaction_clean code where each individual transaction was stripped of it’s white space and placed into individual transactions lists, but the lists were repeated three times.

[['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', 

I am fairly sure this was not the intended output for the desired code and was wondering if anyone can help point me in the write direction.


The above line is nested inside two loops, hence the repetition.


Thank you!

It is small things like this I notice myself looking over. I appreciate the reply.

1 Like

94 posts were split to a new topic: Getting 112 as the number of “whites” in step 20 instead of 28

A post was split to a new topic: ‘list’ object has no attribute ‘strip’