Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by Tiberiu ( 6 years ago )
all_seats = [
    [(1, False, 1), []],
    [(2, False, 1), []],
    [(3, False, 2), []],
    [(4, False, 2), []],
    [(5, True, 1), []],
    [(6, True, 1), []],
    [(7, True, 2), []],
    [(8, True, 2), []],
    [(9, False, 3), []],
    [(10, False, 3), []],
    [(11, False, 4), []],
    [(12, False, 4), []],
    [(13, True, 3), []],
    [(14, True, 3), []],
    [(15, True, 4), []],
    [(16, True, 4), []],
    [(17, True, 0), []],
    [(18, True, 0), []],
    [(19, True, 0), []],
    [(20, True, 0), []],
    [(21, True, 0), []],
    [(22, True, 0), []],
    [(23, True, 0), []],
    [(24, True, 0), []],
    [(25, True, 0), []],
    [(26, True, 0), []],
    [(27, True, 0), []],
    [(28, True, 1), []],
    [(29, False, 5), []],
    [(30, False, 5), []],
    [(31, False, 6), []],
    [(32, False, 6), []],
    [(33, True, 5), []],
    [(34, True, 5), []],
    [(35, True, 6), []],
    [(36, True, 6), []]
]
mainMenu = """
Press:
1 - Display seat reservation
2 - Reserve a seat
3 - See the current status of all seats
4 - Quit
"""
answer = ''
reserved_seats = []


def availability(a):
    if not all_seats[a][1]:
        return "This seat is available!"
    else:
        return "This seat is already reserved!"


def reserving_seat():
    print("In order to have a place reserved we need your name and phone number")
    answer6 = name, phone = input("Enter your name: "), input("Your phone number: ")
    all_seats[answer5 - 1][1].append(answer6)
    print(f"You successfully reserved this seat:\n{all_seats[answer5 - 1]}")


while True:
    try:
        print(mainMenu)
        answer = input("Choose your option: ")
        if answer == "1":
            for i in range(len(all_seats)):
                if not all_seats[i][1]:
                    continue
                else:
                    reserved_seats.append(all_seats[i][0][0])
            print(f"Following seats are already reserved: {reserved_seats} , Total reserved: {len(reserved_seats)}")
            reserved_seats.clear()

        elif answer == "2":
            try:
                user_checking_seat = int(input("Enter a seat number to check its info: "))
                print(f"""Your seat info is: {all_seats[user_checking_seat - 1]}
{availability(user_checking_seat - 1)}   
""")
                answer3 = input("Do you want to reserve a seat? Press y or n: ").lower()
                if answer3 == "y":
                    answer4 = input("Do you want to see all the seats? Press y or n  > ").lower()
                    if answer4 == "y":
                        for i in range(len(all_seats)):
                            print(f"{all_seats[i]}")
                        answer5 = int(input("Reserve a seat (press from 1 up to 36) > "))
                        if not all_seats[answer5 - 1][1]:
                            reserving_seat()
                        else:
                            print(f"{all_seats[answer5 - 1]}")
                            print("This seat is already reserved, you have to choose another one!")
                    elif answer4 == "n":
                        answer5 = int(input("Reserve a seat (press from 1 up to 36) > "))
                        if not all_seats[answer5 - 1][1]:
                            reserving_seat()
                        else:
                            print(f"{all_seats[answer5 - 1]}")
                            print("This seat is already reserved, you have to choose another one!")
                    else:
                        print("Press y or n")
                        continue
                elif answer3 == "n":
                    print("ok :)".center(45))
                    continue
                else:
                    print("Press y or n")
                    continue

            except IndexError:
                print("This seat does not exist! You must enter a number between 1-36")

        elif answer == "3":
            for i in range(len(all_seats)):
                print(all_seats[i])

        elif answer == "4":
            answer2 = input("Are you sure? Press y or n: ").lower()
            if answer2 == "y":
                print("See you soon! :)")
                quit()
            elif answer2 != "n":
                print("Invalid answer!")
                continue
            else:
                continue
        else:
            print("This option does not exist!")

    except ValueError:
        print("Please enter a number!")

 

Revise this Paste

Your Name: Code Language: