Leon Gaban
Leon Gaban

Reputation: 39018

What is the Syntax error in this simple Python file?

following the Python tutorial on Tuts+ and I'm getting a syntax error in my code below:

#!/usr/bin/env python

from bs4 import BeautifulSoup
from urllib import urlopen

html = urlopen('http://www.brainyquote.com/quotes/topics/topic_life.html').read()

soup = BeautifulSoup(html)
for section in soup.findAll('span',{"class":"bqQuoteLink"})
    print section
    break

enter image description here

The tutorial required me to download and install BeautifulSoup, which I did with no errors. The only thing I can think off is that I'm using 4.3 while the tutorial author used 4.1?

Upvotes: 1

Views: 102

Answers (1)

Óscar López
Óscar López

Reputation: 236004

Try this:

for section in soup.findAll('span', {"class":"bqQuoteLink"}):

... You forgot the : at the end of the loop.

Upvotes: 6

Related Questions