Python Film Box Office display occupied seating position

Asked

Viewed 162 times

-1

I’m doing a show using matrices that works like a movie box office.

I am working to finish option 1 (which in my opinion is the most laborious). I was able to change the values in the matrix so that instead of the number appears xx when the user chooses the place where he wants to sit.

My biggest problem is when it comes time to say that the chosen seat is already occupied and show the position where it is occupied. And if you select 2 places to sit down, in case one of these places is occupied, it cannot mark the place valid with xx (the 2 posts are invalid to be filled at the moment).

Part where prints the chosen place with xx:

    for linha in range(entrada_linhas):
        for coluna in range(entrada_colunas):
            if str(m[linha][coluna]).zfill(2) in valores_assentos:
                #adicionando xx nas posições escolhidas
                m[linha][coluna] = "xx"
            print(str(m[linha][coluna]).zfill(2), end="\t")
        print()
    for assentos_ocupados in valores_assentos:
        print("Assento escolhido:", str(assentos_ocupados).replace("0", ""))`

1 answer

0

def IngressosCinemas(posicao,assentos):
   for p,j in enumerate(assentos):
     for o,k in enumerate(j):
       if(posicao==k):
          matriz[p][o] = "XX"

The position variable is the seats chosen, and the variable seats is a list of all the seats in the cinema.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.