[Solved] could not conver string to float


Its hard to answer this without getting more information. I’m assuming your error is on this line:

converted_price = float(price[0:6])

price[0:6] is an array. You cant convert an array to a float like that. In addition, each element may not even be a number, it could be something like this:

 [<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
  <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
  <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]

Here is what I’d do. First print out price, to figure out what exactly it is.

print(price)

Now write some code to extract only the useful stuff from there. First you need to see which element you actually want, then once you find that element use substrings to get out the number. Then you can convert it to a float.

If this helps, please select this as the solution

1

solved could not conver string to float