Thread Shed error

I have an error message that I don’t understand . In this case the message says " trace back (most recent call last):
File “”, line 110, in
daily_sales_replaced = daily_sales.daily_sales.replace(";,;","+")
Attribute Error: ‘str’ object has no attribute ‘daily_sales’"

What does it mean exactly? Attribute Error: ‘str’ object has no attribute ‘daily_sales’" .

Am I missing something in the code?

Thanks in advance.

you’ve got daily_sales.daily_sales.replace…
So, it’s thinking the second daily_sales is an attribute of the first and can’t work out what it’s supposed to be doing.
delete the extra daily_sales. and you should be ok.

Have fun

Yes indeed that suggestion worked

I have an error mesaage on line 141

  File "", line 141, in <module>
    total_sales += float(sale.strip("$"))
ValueError: could not convert string to float: 'y```

Which I don't understand is it a syntax error or the semantics of the code?

That error means that, on line 141, you’re trying to convert a string that contains something other than numbers or a single decimal, into a float. For example:

strng = "123h"

Will throw the same error as yours, since "h" cannot be turned into a float.

  total_sales += float(sale.strip("$"))


would the code   total_sales += float(sale.strip("$"))       not strip "$" and leave only the float?  Or is the construction of the code itself unworkable?

I’m afraid I don’t know the state of the code before the .strip($), but that’s what I imagine’s going on. Your code seems workable; there may just be some space or something that’s causing the error.

yes that’s right the code is working perhaps it is a space or something.

1 Like