CurriculumPython print() for KidsTelling print HOW to speak
Python print() sep and end Arguments Explained
sep and end — the settings that change the shape of what I say.
Telling print HOW to speak
You've been telling me WHAT to say. Now I'll show you how to change HOW I say it.
First: print() can take more than one thing at once. Just put a comma between them.
print("Fire", "Ice")Output
Fire IceNotice the space between them? I put that there myself. You never typed it.
print("Fire", "Ice")Output
Fire IceThat space is a setting called sep — short for separator. You can change it to anything.
print("Fire", "Ice", sep="-")Output
Fire-IceSet it to nothing at all, and the words run straight together.
print("Fire", "Ice", sep="")Output
FireIceThere's a second setting: end. It's what I say AFTER everything else — normally a new line.
print("Fire")
print("Ice")Output
Fire
IceChange end to "" and I don't start a new line at all. I just keep going.
print("Fire", end="")
print("Ice")Output
FireIceCheck your understanding
What will I say here?
print("day", "night", sep="/")Why: sep replaces the space I'd normally put between things, so the slash goes in the middle: day/night. It changes what's BETWEEN, never what's at the end.
How many lines will I say here?
print("up", end="")
print("down")Why: end="" replaces the new line with nothing at all, so the next print starts right where the last one stopped. One line, and the words run together: updown.
What you'll practice
The dragon wants to say your name and your title together, in one breath — not as two separate lines. Hand print() two things at once.
More from this topic
Telling print HOW to speak is one lesson inside Python print() for Kids — see the full lesson order and what the whole topic covers.
View the full topic →