📚
End Character Override
What Happens at the End of print()
You've noticed that each
print()print()\nBut what if you want two prints to appear on the same line? That's what the
endprint()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
endfor i in range(1, 4): print(i, end=" ") # → 1 2 3 (all on one line)
Without
end=" "💡💡 Remember:
controls what goes between multiple values in onesep.print()controls what goes after the entireendis done.print()
main.pySandbox
main.py
Ctrl + Enter