1.Reverse string using stack in python
import stack
string = 'arewen ekil I'
reversed_string = ''
s = stack.Stack()
# your solution here
print(reversed_string)
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)
Comments
Leave a comment