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


You can understand by Watching video :-



Answer -

a = input("Enter a string = ")
for i in range (0 , len(a)+1 , 2 ) :
     print( a [ i - 2 : i])

Output :-

Enter a string = Path

Pa
th

>>>

Enter a string = Portal

Po
rt
al

>>>

5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post