📚

End Character Override

What Happens at the End of print()

You've noticed that each

print()
puts its output on a separate line. That's because, by default,
print()
adds a newline character (
\n
) at the very end.

But what if you want two prints to appear on the same line? That's what the

end
parameter controls — it lets you decide what
print()
adds at the very end.

The Default Behavior

print("Hello")
print("World")
# → Hello
# → World  (each on its own line because end="\n" by default)

Changing the End Character

print("Hello", end=" ")    # End with a space instead of a newline
print("World")
# → Hello World  (same line!)

print("Loading", end="...")
print("Done!")
# → Loading...Done!

Using end in a Loop

This is where

end
really shines — inside a loop, it lets you print everything on one line:

for i in range(1, 4):
    print(i, end=" ")
# → 1 2 3  (all on one line)

Without

end=" "
, each number would appear on its own line!

💡

💡 Remember:

sep
controls what goes between multiple values in one
print()
.
end
controls what goes after the entire
print()
is done.

main.pySandbox
main.py