(non native, go easy on my grammar) I'm doing a college exercise in which I must do a ticket vending program. The problem comes up when I sell the ticket and add 1 to the "TypeSold" variable. Depending on how many ticket types are active, its respective number option will change and causing the wrong variable to go up.
I tried to find a solution using conditionals to check which type is on and adjust the if option==x TypeSold += 1, but i couldnt find a way to do so.
contadorDeOpcoes = 0 contadorDeOpcoes+=1 print(str(contadorDeOpcoes) +"- Comum\n") if IngressoMeia_ativo == "1": contadorDeOpcoes+=1 print(str(contadorDeOpcoes) +"- Meia Entrada\n") if IngressoDesconto_ativo == "1": contadorDeOpcoes+=1 print(str(contadorDeOpcoes) +"-",IngressoDescontoNome,"\n") if IngressoCortesia_ativo == "1": contadorDeOpcoes+=1 print(str(contadorDeOpcoes) +"- Cortesia\n") tipo = (input("Qual tipo de ingresso deseja?\n \n \n")) while not tipo.isdigit(): tipo = (input("Qual tipo de ingresso deseja?\n \n \n")) while 1>int(tipo) or int(tipo)>contadorDeOpcoes: tipo = (input("Qual tipo de ingresso deseja?\n \n \n")) while not tipo.isdigit(): tipo = (input("Qual tipo de ingresso deseja?\n \n \n")) Idade_Comprador = input("\nDigite a idade do comprador\n") while not Idade_Comprador.isdigit(): Idade_Comprador = input("\nDigite a idade do comprador\n") Idade_Comprador = int(Idade_Comprador) Soma_Idade += Idade_Comprador print('''\n\n\n\033[1;32m --------------------------------------------------------------------------------- INGRESSO VENDIDO! \033 ---------------------------------------------------------------------------------\033[m''')
#aqui ele calcula o processo de venda e a quantidade de ingressos restantes /
vendidos
IngressosDisponiveis -= 1 print("\n\nRestam",IngressosDisponiveis,"ingressos\n\n\n") if tipo == "1": VendidosComum += 1 if tipo == "2": VendidosMeia +=1