Thread shed

https://www.codecademy.com/courses/learn-python-3/projects/thread-shed

Can someone please tell me why I’m getting this error?

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)

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)

Save

4.84 34.0 84.07999999999998 104.59999999999997 186.15999999999997 309.43999999999994 316.84000000000003 Traceback (most recent call last): File “script.py”, line 145, in total_sales += float(sale.strip("$")) ValueError: could not convert string to float: ‘\n$17.98’

1 Like

Hey,

You need to check what comes out of sale.strip("$") when you call float(sale.strip("$")) to be sure.

The error message is telling you it can’t convert ‘\n$17.98’ even when it’s stripped of $…
If there’s other items like it in the loop you’ll have to deal with them too.

For future reference, remember you can format your code by highlighting and pressing the </> button. It’ll make it easier to pinpoint issues :slight_smile:

2 Likes