Haroon Haroon - 2 years ago 380
Python Question

How to fix a syntax error with print in Python 3?

I have installed bs4 and Python 3.4.4.

>>> print soup.prettify()
File "<stdin>", line 1
print soup.prettify()
Syntax Error: invalid syntax

Answer Source

In Python 3.x, print is a function, not a statement.

So, you want to call it as print(soup.prettify()).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download