dimanche 4 octobre 2020

If statement is not working in python, here is my code:

from queue import LifoQueue
stack = LifoQueue()
length = int(input())
string = input()
stack.put(string[0])
for ch in string[1:]:
    char = stack.get()
    if not(ch==char):
        print("inside else")
        stack.put(char)
        stack.put(ch)
result = ''
while not stack.empty():
    result = stack.get()+result
print(len(result))
print(result)

Aucun commentaire:

Enregistrer un commentaire