Python typeError
Question: I am new to programming. I am trying to download race results using Python and
Mechanize. I tried to loop through the pages by creating a `for` loop I have
included the relevant code below. When I run this I get the following error:

TypeError: unsupported operand type(s) for %: 'instance' and 'int'

Why can't I use the variable x in the URL?

    
    
    import mechanize
    
    br = mechanize.Browser()
    
    for x in range(1, 3): 
        page = br.open('http://results.chicagomarathon.com/2013/?page=%d&event=MAR') % (x)
        print page.read()
    


Answer: The problem is that you are trying to format the response of mechanize with
the integer when you should be formatting the url.

The following code formats the url and then tries to retrieve it:

    
    
    import mechanize
    
    br = mechanize.Browser()
    
    for x in range(1, 3):
         url = 'http://results.chicagomarathon.com/2013/?page=%d&event=MAR' % (x)
         page = br.open(url)
         print page.read()
    

