❓ Help Fixer help (for bot only)

V_1 M

Forum Guru

humanize and fix the missing codes in pythone code below:

# lets assume na initial seat available is 10
seats = [False] * 10
def check_available_seats():
available_seats = [i+1 for i, seat in enumerate(seats) if not seat]
return available_seats
# Starting seat reservation
def reserve_seat(seat_number):
if 1 <= seat_number <= 10:
if not seats[seat_number - 1]:
seats[seat_number - 1] = True
print(f"Seat {seat_number} successfully reserved.")
else:
print(f"Seat {seat_number} is already taken.")
else:
print("Invalid seat number.")
# Trying to cancel seat
def cancel_seat(seat_number):
if 1 <= seat_number <= 10:
if seats[seat_number - 1]:
seats[seat_number - 1] = False
print(f"Seat {seat_number} reservation successfully cancelled.")
else:
print(f"Seat {seat_number} is not currently reserved.")
else:
print("Invalid seat number.")
# initial promt visualization
print(" âœˆï¸ WELCOME TO CIT_A AUTOMATED BOOKING âœˆï¸ ")
# Loop
while True:
print(" _______________________________")
print("| 1.] Check available seats |")
print("| 2.] Reserve a seat |")
print("| 3.] Cancel a seat reservation |")
print("| 4.] Exit. |")
print("|_______________________________|")

print(" ")
choice = input("Enter your command: ")

# validation of user input
if choice == '1':
available_seats = check_available_seats()
print(f"Available seats: { available_seats}")
elif choice == '2':
seat_number = int(input("Enter the seat number you want to reserve: "))
reserve_seat(seat_number)
elif choice == '3':
seat_number = int(input("Enter the seat number you want to cancel: "))
cancel_seat(seat_number)
elif choice == '4':
print("Program Ended. Thank you! Come again")
break
else:
print("Invalid choice. Please enter corresponding number representing each line of command.")
 

About this Thread

  • 2
    Replies
  • 224
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,114
Guests online
993
Total visitors
2,107

Forum statistics

Threads
2,273,795
Posts
28,951,734
Members
1,234,958
Latest member
Steavin31
Back
Top