Thread Shed Python Strings Project

Hello! Programming newbie here. I am working through the Computer Science pathway. I am currently trying to complete the Thread Shed project in the Python: Strings module, however I am having a bit of trouble. I’ve copied my code below.
Whenever I print the lists I’ve created (customer, sale, and thread_sold) to the console, I get 4 instances of on piece of data.
For example:
customers = [[‘Edith Mcbride’, ‘Edith Mcbride’, ‘Edith Mcbride’, ‘Edith Mcbride’, ‘Herbert Tran’, ‘Herbert Tran’, ‘Herbert Tran’, ‘Herbert Tran’, ‘Paul Clarke’, ‘Paul Clarke’, ‘Paul Clarke’, ‘Paul Clarke’, ‘Lucille Caldwell’, ‘Lucille Caldwell’, ‘Lucille Caldwell’, ‘Lucille Caldwell’,… and so on]

I’ve been going over my code and I can’t seem to understand why this is happening. Is there anyone who knows why I’m getting this output?

Thread Shed Project


daily_sales_replaced = daily_sales.replace(';,;','|')
daily_transactions = daily_sales_replaced.split(',')

daily_transactions_split = []
for transaction in daily_transactions:
  daily_transactions_split.append(transaction.split('|'))
#print(daily_transactions_split)

transaction_clean = []
for transaction in daily_transactions_split:
  transaction_cleaner = []
  for data in transaction:
    transaction_cleaner.append(data.replace('\n', ' ').strip(' '))
    transaction_clean.append(transaction_cleaner)

customers = []
sale = []
thread_sold = []
for transaction in transaction_clean:
  customers.append(transaction[0])
  sale.append(transaction[1])
  thread_sold.append(transaction[2])    

print(customers)
print(sale)  
print(thread_sold)

Did you happen to search the forums for this question? There are probably over 50 threads on this exact issue. (For ex—I just answered this very same question the other day.)
I suggest reading other threads first to see if you can fix your error.

I figured it out. Thank you :grinning:

1 Like

hi could you tell me how u solved this problem i’ve been looking through the other forums and i couldnt find out how to solve i.