Thread Shed AttributeError: 'list' object has no attribute 'strip'

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 am stuck at step 14 of thread shed

My code is exactly like the walk through video but I keep getting an attribute error

my code.

customers = []
sales = []
thread_sold = []

for transaction in transactions_clean:

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

The error:
Traceback (most recent call last):
File “”, line 139, in
total_sales += float(sale.strip("$"))
AttributeError: ‘list’ object has no attribute ‘strip’

Can somebody help me understand what I’m doing wrong?

You might want to work backwards from that error. It’s not necessarily easy but debugging is an essential part of programming, humans make mistakes and even if you’re somehow perfect it doesn’t mean that everyone else is. So you need to learn how to find these errors.

Start with the information provided; sale has no strip attribute because it’s a list. OK, so it’s not the type we expect. Where do we get sale from? Back up a step or two and we find sale is an element of sales. So… where is sales defined. So sales is as a list sales = [] and it is populated by appending the second element of transaction.

So sale ≈ transaction[1]. So where does transaction come from? It is an element of transactions_clean. Chances are there’s something a little wrong with transactions_clean. That’s as much code as you’ve provided, you’ll need to keep digging for this one.