Project, thread shed

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

I can’t figure out why, but the console is printing out each item 4 times in a row. —
[[‘Edith Mcbride’, ‘$1.21’, ‘white’, ‘\n09/15/17’], [‘Edith Mcbride’, ‘$1.21’, ‘white’, ‘\n09/15/17’], [‘Edith Mcbride’, ‘$1.21’, ‘white’, ‘\n09/15/17’], [‘Edith Mcbride’, ‘$1.21’, ‘white’, ‘\n09/15/17’], [‘Herbert Tran’, ‘$7.29’, ‘\nwhite&blue’, ‘09/15/17’], [‘Herbert Tran’, ‘$7.29’, ‘\nwhite&blue’, ‘09/15/17’], [‘Herbert Tran’, ‘$7.29’, ‘\nwhite&blue’, ‘09/15/17’], [‘Herbert Tran’, ‘$7.29’, ‘\nwhite&blue’, ‘09/15/17’], [‘Paul Clarke’, ‘$12.52 \n’, ‘white&blue’, ‘09/15/17’], [‘Paul Clarke’, ‘$12.52 \n’, ‘white&blue’, ‘09/15/17’], [‘Paul Clarke’, ‘$12.52 \n’, ‘white&blue’, ‘09/15/17’], [‘Paul Clarke’, ‘$12.52 \n’, ‘white&blue’, ‘09/15/17’]

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)

transactions_clean =
for transaction in daily_transactions_split:
transaction_clean =
for data_point in transaction:
transaction_clean.append(data_point.replace(“\n”,“”).strip(" "))
transactions_clean.append(transaction_clean)

print(transactions_clean)

customers =
sales =
thread_sold =

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

print(customers)

print(sales)

print(thread_sold)

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

print(total_sales)

what am I doing wrong???

1 Like

hi @wlang2602 first please format your code
and I will help.

2 Likes

sorry I forgot yo can’t format your code yet

Did you ever discover a solution to this issue? I am having the same problem. I worked through this project on my own, up until the part where you separate the transactions into three different lists. I had to use three different for loops and wondered if there was a more efficient way to do this; leading me to watch the walk through video and edit my code to match the instructor’s. I was able to separate the transactions into sub-lists-rather than all data points in one giant list- but everything is quadrupled like you said.

If you- or anyone else- can help, I’d be grateful!

Ah, apologies for rezzing a dead thread and then immediately solving the issue on my own. But here is the solution for anyone who may stumble across this thread with the same issue.

In the walk through video, “transaction_clean.append(data_point.strip())” and “transactions_clean.append(transaction_clean)” appear to have the same indentation. However, “transaction_clean.append(data_point.strip()” should be indented underneath the inner loop (for data_point in transaction:), while “transactions_clean.append(transaction_clean)” is indented one layer higher; within the outermost loop.

1 Like