I began learning Python a little time ago, and I got the first problem. Here’s the code:
fh = open('/usr/share/dict/words')
for line in fh.readlines():
print(line, end='')
When I execute it in the Terminal (OS X), it tells me invalid syntax error where end equal sign is placed. What’s the problem here? Didn’t find the solution…
I installed Python 3.3.0 from this page, Python 3.3.0 Mac OS X 64-bit/32-bit x86-64/i386 Installer
Sorry for so nooby questions 🙁
The Python 3 installer does not make Python 3 the default Python (if it did, it would break a ton of stuff, because very few Python scripts are Python 3 compatible). So to get Python 3, you should execute your script as
python3 script.py, or add#!/usr/bin/env python3to the top of the file.