Python Practice › String Programs › Program 104

Each character on a new line

EasyString Programs · 104 of 106

Write a Python program to print each character on its own line.

Advertisement
Input
"python"
Output
p
y
t
h
o
n

Approach

  1. Loop or print(*text, sep="\n").

Solution

Python
print(*"python", sep="\n")
Output
p
y
t
h
o
n

Line by line

Line 1

* unpacks the string into separate characters and sep="\n" puts each on its own line.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs