What am I doing wrong in thread shed?

For some reason, I keep ending up with 24. Why is that? Below is my code. Help would be greatly appreciated.
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(“@”))

transactions_clean =

for transaction in daily_transactions_split:
transaction_clean =
for data_point in transaction:
transaction_clean.append(data_point.strip())
transactions_clean.append(transaction_clean)

customers =
sales =
thread_sold =

for transaction in transactions_clean:
customers.append(transaction[0])
sales.append(transaction[1])
thread_sold.append(transaction[2])

total_sales = 0

for sale in sales:
total_sales += float(sale.strip(“$”))

threads_sold_split =

for thread in thread_sold:
if “&” in thread:
thread.split(“&”)
threads_sold_split.append(thread)
else:
threads_sold_split.append(thread)

def color_count(color):
color_total = 0
for thread_color in threads_sold_split:
if color == thread_color:
color_total += 1
return color_total

colors = [“red”,“yellow”,“green”,“white”,“black”,“blue”,“purple”]

for color in colors:
print(“Thread Shed sold {} threads of {} thread today.”.format(color_count(color), color))

Did you follow these steps first?

You seem to have

    if "&" in thread:
      thread.split("&")
      threads_sold_split.append(thread)

Here, thread.split("&") returns an list, which you did not use;
instead you put the thread string into the list.
But .split does not change the original string.

I assume you want to add all the elements of the list from thread.split("&")   to   threads_sold_split

    if "&" in thread:
      split_thread = thread.split("&")
      threads_sold_split.extend(split_thread)

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