Answer to Question #270395 in Python for xxx

Question #270395

1.Reverse string using stack in python

 

import stack

 

string = 'arewen  ekil  I'

reversed_string = ''

s = stack.Stack()

 

# your solution here

 

print(reversed_string)


1
Expert's answer
2021-11-23T11:23:14-0500
import stack

 

string = 'arewen  ekil  I'

reversed_string = ''

s = stack.Stack()

n = len(string)
for i in range(n):
  s.push(string[i])
for i in range(n):
  reversed_string += s.pop()


print(reversed_string)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS