Ramon Geronimo
PRO
3 days ago
Ramoncountry asked

What happens if i write two print codes on the same line?

N
Expert
yesterday
Nisha Sharma answered

If you try to write two print() statements on the same line, Python needs a clear separator between them. Without one, Python won’t know where the first print() ends and the next one begins, so you’ll get a syntax error.

For example, this won’t work:

print("Hello") print("World")

But this works perfectly, because the semicolon ; separates the two commands:

print("Hello"); print("World")

You’ll see:

Hello
World

Hope that helps. Feel free to ping if you need more help or have any more questions.

Python
This question was asked as part of the Learn Python Basics course.