Q. A line of text is read from the input terminal into a stack. Write a program to output the string in reverse order, each character appearing twice. (e.g., the string a  b c d e should be changed to ee dd cc bb aa)

 

Answer = 


You can understand by Watching video :-



line = input("Enter a line : ")
stack = [  ]
for i in line :
    stack.append(i+i)

stack.reverse()

for j in stack :
    print( j , end=" ")

Output :-

Enter a line : This is Path Walla Website.
.. ee tt ii ss bb ee WW    aa ll ll aa WW    hh tt aa PP    ss ii    ss ii hh TT

>>>

Post a Comment

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

Previous Post Next Post