I am trying to parse a string which contains a number and when I try to convert it to a float, it gives me an error:
ValueError: could not convert string to float: '8,900'
My code:
soup=BeautifulSoup(content,"html.parser")
element=soup.find("div",{"class":"_1vC4OE _3qQ9m1"})
price=element.text
price_without_symbol=price[1:]
print(float(price_without_symbol));
Output:
"C:\Users\SHIVAM TYAGI\PycharmProjects\price-of- chair1\venv\Scripts\python.exe" "C:/Users/SHIVAM TYAGI/PycharmProjects/price-of-chair1/src/app.py" Traceback (most recent call last): File "C:/Users/SHIVAM TYAGI/PycharmProjects/price-of-chair1/src/app.py", line 9, in print(float(price_without_symbol)); ValueError: could not convert string to float: '8,900'