KnowledgeBoat Logo

Computer Science

Write a Python script that traverses through an input string and prints its characters in different lines — two characters per line.

Python String Manipulation

75 Likes

Answer

str = input("Enter the string: ")
length = len(str)
for a in range(0, length, 2):
    print(str[a:a+2])

Output

Enter the string: KnowledgeBoat
Kn
ow
le
dg
eB
oa
t

Answered By

44 Likes


Related Questions