float change from python 3.0.1 to 3.1.2
Posted
by Jeremy
on Stack Overflow
See other posts from Stack Overflow
or by Jeremy
Published on 2010-04-06T17:42:18Z
Indexed on
2010/04/06
17:43 UTC
Read the original article
Hit count: 286
python
Im trying to learn python. I am using 3.1.2 and the o'reilly book is using 3.0.1 here is my code import urllib.request
price = (99.99)
while price > 4.74: page = urllib.request.urlopen ("http://www.beans-r-us.biz/prices-loyalty.html") text = page.read().decode("utf8")
where = text.find('>$')
start_of_price = where + 2
end_of_price = start_of_price + 6
price = float(text[start_of_price:end_of_price])
print ("Buy!")
- here is my error Traceback (most recent call last): File "/Users/odin/Desktop/Coffe.py", line 14, in price = float(text[start_of_price:end_of_price]) ValueError: invalid literal for float(): 4.59
>>>
what is wrong? please help!!
© Stack Overflow or respective owner