CBSE Class 11 Computer Science
Question 41 of 91
String Manipulation — Question 1
Back to all questions 1
Question Question 1
Write a Python script that traverses through an input string and prints its characters in different lines — two characters per line.
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