##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 06\06.13 - Controlling the occupancy of movie theaters.py
# Description: Controlling the occupancy of movie theaters
##############################################################################
vacant_places = [10, 2, 1, 3, 0]
while True:
room = int(input("Room (0 to exit): "))
if room == 0:
print("End")
break
if room > len(vacant_places) or room < 1:
print("Invalid room")
elif vacant_places [room - 1] == 0:
print("Sorry, the room is full!")
else:
places = int(input(f"How many places do you want ({vacant_places [room - 1]} vacant):"))
if places > vacant_places[room - 1]:
print("This number of seats is not available.")
elif places < 0:
print("Invalid number")
else:
vacant_places[room - 1] -= places
print(f"{places} places sold")
print("Rooms occupancy")
for room, vacant in enumerate(vacant_places):
print(f"Room {room + 1} - {vacant} empty place (s)")