Thread Shed, step 11

I hate to ask…but I’m obviously missing something…
I’m iterating through the clean transactions list, appending each customer, sale, and thread sold to a different list. I’m printing the items before appending, and they look fine. To make a long story short I’m getting 3 copies of the same list. I apologize if I’m getting confusing…

Code:
#------------------------------------------------

Start coding below!

def cleanup_daily_transactions(rec):
transactions_clean =
for rec in daily_transactions_split:
cleaned_daily_transaction = stripped_word=
for word in rec:
word.replace("\n"," “)
stripped_word = word.strip()
cleaned_daily_transaction.append(stripped_word)
transactions_clean.append(cleaned_daily_transaction)
return transactions_clean
#Main Program__
word = daily_sales_strip = “”
daily_sales_replaced = daily_transactions = daily_transactions_split = transactions_clean =
customers = sales = threads_sold =
daily_sales_replaced = daily_sales.replace(”;,;","|")
daily_transactions = daily_sales_replaced.split(",")
for word in daily_transactions:
daily_transactions_split.append(word.split("|"))
transactions_clean = cleanup_daily_transactions(daily_transactions_split)
customers = sales = threads_sold =
for tran in transactions_clean:
print(“Rec 0, 1, 2:")
print(str(tran[0]))
print(str(tran[1]))
print(str(tran[2]))
print("Cust/Sales/Threads:
")
customers.append(tran[0])
sales.append(tran[1])
threads_sold.append(tran[2])
print("
==")
print(str(customers))
print(str(sales))
print(str(threads_sold))
print("
_______**__________”)

Output (Edith Mcbride:)
Rec 0, 1, 2:_______
Edith Mcbride
$1.21
white
Cust/Sales/Threads:____
==____
[‘Edith Mcbride’, ‘$1.21’, ‘white’]
[‘Edith Mcbride’, ‘$1.21’, ‘white’]
[‘Edith Mcbride’, ‘$1.21’, ‘white’]
**____

Thanks very much for your help.

There were indentations (for, etc…this is my first post here - I didn’t realize spaces would get stripped.)

Hello, @object0562296124, and welcome to the forums!

Please review How do I format code in my posts?

It will show you how to preserve your code’s original formatting when you paste it here in the forums.

As is, it’s hard to tell what is nested where since there is no indentation shown, but if you are getting something more than once that you only wanted once doesn’t that seem like it may be unintentionally inside a loop?

1 Like