float change from python 3.0.1 to 3.1.2
Question: I'm 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 <module>
        price = float(text[start_of_price:end_of_price])
    ValueError: invalid literal for float(): 4.59</
    >>> 
    

What is wrong?


Answer: The problem is that you have extra characters at the end of your float,
probably because the content of the page changed since the code was written
(the number appears to change every fifteen minute). You could try changing
the following line to make the code slightly more robust:

    
    
    end_of_price = text.find('<', start_of_price)
    

For an even better solution you should use something like
[BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/) to parse the
HTML.

