Listing 06-07: Simulation of a bank line

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 06\06.07 - Simulation of a bank line.py
# Description: Simulation of a bank line
##############################################################################

last = 10
line = list(range (1, last + 1))
while True:
    print(f"\nThere are {len(line)} customers in the line")
    print(f"Current line: {line}")
    print("Type F to add a customer to the end of the line,")
    print("or A to perform the service. S to leave.")
    operation = input("Operation (F, A, or S):")
    if operation == "A":
        if len(queue) > 0:
            attended = line.pop(0)
            print(f"Customer {attended} served")
        else:
            print("Empty line! Nobody to serve.")
    elif operation == "F":
        last += 1 # Increase the new customer's ticket
        line.append(last)
    elif operation == "S":
        break
    else:
        print("Invalid operation! Type F, A, or S!")
Click here to download the file