Skip to content

Instantly share code, notes, and snippets.

@brymer-meneses
Created November 4, 2021 07:19
Show Gist options
  • Save brymer-meneses/3879f60f7ab8c861edbf06df4d9ec1a3 to your computer and use it in GitHub Desktop.
Save brymer-meneses/3879f60f7ab8c861edbf06df4d9ec1a3 to your computer and use it in GitHub Desktop.
# initialize 2d array
bus = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
]
# ask for reserved number
seat_number = int(input("Please the seat number you want to reserve: "))
# check for invalid choices
while seat_number <= 0 or seat_number > 16:
print("Invalid seat number, must be in the interval [1, 16]")
seat_number = int(input("Please pick again: "))
x, y = divmod(seat_number, 4)
name = input("Please enter your name: ")
for row in bus:
for element in row:
if element == name:
name = input("Name taken, please enter another name: ")
bus[x - 1][y - 1] = name
payment = int(input("That would be P100, please enter your payment in pesos: "))
if payment < 100:
print("Invalid payment payment should be > 100")
payment = int(input("your payment: "))
else:
print(f"Your change is {payment - 100}")
print("Have a nice day!")
print(bus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment