AlgoBazaAlgoBaza
Python for kids ยท Module 1

Lesson 8

sep and end in print

After this lesson: You'll change what print puts between the values (sep) and what it prints at the end of the line (end).

Video

?

The video for this lesson is coming soon.

Explanation

You already know two things about print: a comma puts a space between values, and every print ends with a new line. Today you'll learn to change both habits! ๐Ÿ› ๏ธ

sep - what goes between the values

Normally print(1, 2, 3) prints 1 2 3 - there's a space between the values. You can change that: at the end, after a comma, add sep="..." (short for separator).

  • print(1, 2, 3, sep="-") prints 1-2-3,
  • print(1, 2, 3, sep="") prints 123 - an empty separator glues the values together.

The separator goes only between the values - not at the start and not at the end.

Bajtek writes a date on an invitation ๐ŸŽฌ

Click Next to go step by step.

Bajtek
When's the party?๐Ÿง’
๐Ÿ’Œ๐ŸŽฏ16.10.2026
1

A birthday invitation

Bajtek is making birthday invitations. He wants to print the date the way it's written in a notebook: 16.10.2026 - with dots.

Step 1 / 7

A dash instead of a space

First a normal print - there's a space between the names. Then the same print with sep="-" - a dash appears where the space was.

โ€ฆ
?

Click the arrow - you'll see what print puts between the values.

Code
1print("Ala", "Ola")
2print("Ala", "Ola", sep="-")
Screen
โ–
1/3 ยท line 1 runs next

The same three, different separators

The values are the same - only what stands between them changes.

โ€ฆ
?

Click the arrow - you'll see what print puts between the values.

Code
1print(1, 2, 3)
2print(1, 2, 3, sep="-")
3print(1, 2, 3, sep="")
4print(1, 2, 3, sep=" and ")
Screen
โ–
1/5 ยท line 1 runs next

A separator only between

The same separator stands between every pair of values - but never at the end. And when there's only one value, there's nothing to separate: no dash at all.

โ€ฆ
?

Click the arrow - you'll see what print puts between the values.

Code
1print("x", "y", "z", sep="+")
2print("x", "y", "z", sep="*")
3print("x", "y", "z", sep=" - ")
4print("x", sep="-")
Screen
โ–
1/5 ยท line 1 runs next
?

What does the program print?

print("a", "b", "c", sep="+")

A date and a time ๐Ÿ“…

The same kind of numbers, different separators: a dash for the date, a colon for the time.

โ€ฆ
?

Click the arrow - you'll see what print puts between the values.

Code
1print(15, 10, 2026, sep="-")
2print(15, 10, 2026, sep=".")
3print(12, 45, sep=":")
Screen
โ–
1/4 ยท line 1 runs next

Glued without spaces

sep="" puts nothing in - the values stand right next to each other.

Code
1print("Ala", "Ola", "Kuba")
2print("Ala", "Ola", "Kuba", sep="")
3print("Ala", "Ola", "Kuba", sep=", ")
Screen
โ–
1/4 ยท line 1 runs next

end - what goes at the end of the line

Normally every print moves to a new line at the end, which is why the next print writes below. With end="..." you say what goes at the end instead of the new line:

  • print("Ala", end=" ") - a space at the end, and the next print writes on in the same line,
  • print("Ala", end="") - nothing at the end: the next print sticks on straight away.

Bajtek counts down to the rocket launch ๐ŸŽฌ

Click Next to go step by step.

Bajtek
Let's count down!๐Ÿง’
๐Ÿš€๐ŸŽฏ3 2 1 Start!
1

A countdown on one line

Bajtek is building a rocket ๐Ÿš€ and wants the countdown on one line: 3 2 1 Start!

Step 1 / 7

First two lines, then one

Lines 1-2: normal prints - each ends with an Enter โŽ, so there are two lines. Lines 3-4: the same text, but the first print has end=" " - it puts a space instead of the Enter and the second print writes on.

๐Ÿ–ฅ๏ธ Lines on the screen

โ–

?

Click the arrow - you'll see what every print puts at its end.

Code
1print("Ala")
2print("has a cat")
3print("Ala", end=" ")
4print("has a cat")
Screen
โ–
1/5 ยท line 1 runs next

Two prints, one line

Watch the screen: after the first print the cursor stays on the same line.

Code
1print("Ala", end=" ")
2print("has a cat")
3print("[", end="")
4print("###", end="")
5print("]")
Screen
โ–
1/6 ยท line 1 runs next

Three different endings

Each time two prints: Ola and a question mark. Without end - two lines. With end=" " - one line with a space. With end="" - one line without a space.

Code
1print("Ola")
2print("?")
3print("Ola", end=" ")
4print("?")
5print("Ola", end="")
6print("?")
Screen
โ–
1/7 ยท line 1 runs next
?

What does the program print?

print("Bajtek", end="")
print("!")

A train of wagons ๐Ÿš‚

Every print adds one wagon, and end="-" puts a coupling after it. The last wagon has no end - it ends the line normally.

๐Ÿ–ฅ๏ธ Lines on the screen

โ–

?

Click the arrow - you'll see what every print puts at its end.

Code
1print("[LOK]", end="-")
2print("[A]", end="-")
3print("[B]", end="-")
4print("[C]")
Screen
โ–
1/5 ยท line 1 runs next

A loading bar โณ

Every piece is added to the same line, because end="" doesn't go down.

Code
1print("Start", end="")
2print(".", end="")
3print(".", end="")
4print(".", end="")
5print("OK")
Screen
โ–
1/6 ยท line 1 runs next

sep and end together

You can use both in one print: sep says what goes between the values, and end - what goes at the end.

The time and lunch ๐Ÿฝ๏ธ

sep=":" glues the time together, and end=" " puts the word lunch on the same line.

Code
1print(12, 30, sep=":", end=" ")
2print("lunch")
Screen
โ–
1/3 ยท line 1 runs next

A date on an invitation ๐Ÿ“…

sep="." puts dots between the numbers of the date, and end=" - " adds a dash with spaces at the end - the next print writes on in the same line.

Code
1print(16, 10, 2026, sep=".", end=" - ")
2print("Bajtek's birthday")
Screen
โ–
1/3 ยท line 1 runs next

The guest list ๐ŸŽฌ

sep=", " puts a comma and a space between the names, and end=" " keeps the rest of the sentence on the same line.

Code
1print("Ala", "Ola", "Kuba", sep=", ", end=" ")
2print("go to the cinema")
Screen
โ–
1/3 ยท line 1 runs next

A cinema ticket ๐ŸŽŸ๏ธ

Four prints, but one line on the screen! Every print has its own end, so the next one writes on. Inside, sep glues the date with dots and the time with a colon. Only the last print, without end, ends the line.

Code
1print("Ticket", end=": ")
2print(16, 10, 2026, sep=".", end=", ")
3print(18, 30, sep=":", end=", ")
4print("row", 5, "seat", 12)
Screen
โ–
1/5 ยท line 1 runs next

Common mistakes

  • sep and end go at the end, after all the values: print(1, 2, sep="-").
  • sep="" (empty) is not the same as sep=" " (a space).
  • After end="" the next print doesn't start a new line - if you want to go down, you need a plain print().

Remember

  • sep="..." - what goes between the values (normally a space).
  • end="..." - what goes at the end of the line (normally a new line).
  • With end="" or end=" " the next print writes on in the same line.

Now you're the one setting up print! The tasks are waiting. ๐Ÿ› ๏ธ

Tasks from the video

We solve them together in the video - pause it and try first on your own.

Practice tasks

Try to solve them without the video. Stuck? Every task has hints and an editorial.

Sign in to save your progress.