I can not run this giving error of undo what is wrong

0
def main():

    q = Queue()
    i=1


    while(q.isFull()==False):
        digitado = input ("digite um numero para inserir na fila: ")
        numLido = int(digitado)
        q.enqueue(numLido)
        i+=1


    while (True):

        x = input ("Digite uma opção: ")       
        print ("1. Imprimir uma fila (sem destruí-la)")
        print ("2. Copiar uma fila para outra")
        print ("3. Verificar se duas filas são iguais")
        print ("4. Remover um elemento da fila, conservando o restante da fila.")
        print ("0. Para SAIR")

        if (x == 1):
            q.imprime()

        elif (x == 2):

        elif (x == 3):

        elif (x == 4):

        elif (x == 0):
            print ("SAIU...")
            break
        else:
            print("ERRO! ")       

if name=="main": 
    main()
    
asked by anonymous 14.03.2017 / 03:06

1 answer

3

I do not know where this Queue class is coming from, but if it's from Python itself, from queue module, there are many errors in your program. But considering that it is a proper implementation and that all methods used exist, ready the errors:

  • Your condition to run main is wrong. The correct one is:

    if __name__ == "__main__":
        main()
    
  • It does not make sense to read the option before displaying the possibilities and if it is to be compared with integer values, it is necessary to convert it to integer.

    print ("1. Imprimir uma fila (sem destruí-la)")
    print ("2. Copiar uma fila para outra")
    print ("3. Verificar se duas filas são iguais")
    print ("4. Remover um elemento da fila, conservando o restante da fila.")
    print ("0. Para SAIR")
    x = int(input("Digite uma opção: "))
    
  • Your indentation problem is in elif which does not execute any code. Python does not allow this. If you want to implement the logic later, but still maintain the conditions, use the pass directive.

    if (x == 1):
        q.imprime()
    
    elif (x == 2):
        pass
    
    elif (x == 3):
        pass
    
    elif (x == 4):
        pass
    
    elif (x == 0):
        print ("SAIU...")
        break
    else:
        print("ERRO! ") 
    
  • 14.03.2017 / 03:52