I\'m using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I\'ve entered, and I am unable to figure out how to add an additional line of code e.g
In case you're looking to use a loop, the : at the end of the line, as other pointed, out will change your prompt to one that looks like this:
...
Just wanted to add that in case you're typing a long line of code and wanted to break it up for aesthetic reasons, hitting shift + enter forces the interpreter to take you to a new line with the ... prompt.
From there, type in the rest of your code and execute as you would with a loop or if statement and your code will execute as expected!
Here's a code snippet from a SQLAlchemy tutorial that exploits this behavior:
>>> session.add_all([
... User(name='wendy', fullname='Wendy Williams', password='foobar'),
... User(name='mary', fullname='Mary Contrary', password='xxg527'),
... User(name='fred', fullname='Fred Flinstone', password='blah')])
To recreate this, you'd use shift + enter after the first line to be able to create the first User object in a new line. Once at the ..., a simple enter press will give you another line with the ... prompt. To exit, simply hit enter at that prompt to return to the > prompt.