Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Paula Wills
Paula Wills
2,893 Points

help(print) function not working in my terminal (mac)

When I type help(print) in my mac terminal, I get: File "<stdin>", line 1 help(print) ^ SyntaxError: invalid syntax

Are you using workspaces's terminal or are you using your personal terminal?

3 Answers

andren
andren
28,558 Points

By default Mac OS ships with Python 2, not Python 3 which is used and thought on Treehouse. In Python 2 print is not technically a function like it is in Python 3, but instead a statement. It can still be used similarly to a function, but internally it is not classified as such.

That is why the help command does not work. If you want to see the help page for statements you have to enclose the name of the statement in quotes like this:

help('print')

That will produce the help page for the print statement in Python 2.

Paula Wills
Paula Wills
2,893 Points

Personal. It works in worksheets, but not in my personal terminal.

Paula Wills
Paula Wills
2,893 Points

Thank you so much for explaining this!