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
State whether the following statement is True or False :
The partition() function's result is always a 3-element tuple.
State whether the following statement is True or False :
The split() returns always a 3-element list.
Out of the following operators, which ones can be used with strings in Python?
=, -, *, /, //, %, >, <>, in, not in, <=
What is the result of following statement, if the input is 'Fun'?
print(input("…") + "trial" + "Ooty" * 3)