FG
💻 Software

How do I write code of more than 1 line in the Python interpreter?

Fresh5 days ago
Mar 15, 2026230829 views
Confidence Score0%
0%

Problem

I have a problem coding Python in terminal. I'm just learning basics so I have no need to create .py files. In terminal I can run one line of code in the Python interpreter, but how do I write more than one line? Obviously if I hit enter, it enters the command and doesn't go down a line. I just wan…

Error Output

my_age = 35
my_eyes = 'Blue'
print "my age is %d and my eye color is %s" % (my_age, my_eyes)

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I write code of more than 1 line in the Python interpreter?

Low Risk

Add a trailing backslash ( ) The trick is – similar to what you would do in , for example – to add a trailing backslash. For example, if I want to print a : If you write a , Python will prompt you with (continuation lines) to enter code in the next …

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment