CBSE Class 12 Computer Science Question 53 of 105

Python Revision Tour II — Question 2

Back to all questions
2
Question

Question 2

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

Answer
name = input("Enter name:")
for i in range(0, len(name), 2):
    print(name[i:i+2])
Output
Enter name:python
py
th
on