We're using Python stack to produce reverse output qwert -> trewq
b=input("Please enter:")
text=list(b)
a=[]
def push():
a.append(text[-1])
def pop():
text.remove(text[-1])
for i in text:
if len(i) != 0:
push()
pop()
else:
print(a)
I did this, but the repetition door stopped in the middle, so what should I do?
python stack
Check where and what kind of problems are occurring by printing them out one by one.
You don't know what you want to do or what's wrong with just the code you uploaded.
If you simply want to print it in reverse order, you can do this.
a = [1, 2, 3, 4, 5]
for i in a[::-1]:
print(i)
Maybe you'll find out what the problem was if you check this out.
a = [1, 2, 3, 4, 5]
for i in a:
print(i)
if i == 2:
a.remove(i)
© 2024 OneMinuteCode. All rights reserved.