Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- import copy
- def building_seats(row, seats):
- seats_list = []
- row_list = []
- alpha_list = []
- alpha_list = [chr(x) for x in range(ord('A'), ord('Z') + 1)]
- for s in alpha_list[0:seats]:
- seats_list.append(s)
- str_seats = ' '.join(seats_list)
- for i in range(1, row + 1):
- row_list.append(i)
- print(i, str_seats)
- seats_list = [seats_list]*seats
- reservering_seat(seats_list, row)
- def reservering_seat(seats_list, row):
- row2, reserved_seat = input("Input seat number (row seat): ").split()
- row3 = int(row2)
- seats_list_copy = copy.deepcopy(seats_list)
- for index, value in enumerate(seats_list_copy[row3]):
- if value == reserved_seat:
- seats_list_copy[[row3][index]].remove(value)
- seats_list_copy[[row3][index]].insert(index, "X")
- print(seats_list_copy)
- printing_updated_seats(seats_list_copy, row)
- def printing_updated_seats(seats_list_copy, row):
- fixed_list = [val for sublist in seats_list_copy for val in sublist]
- fixed_list = list(dict.fromkeys(fixed_list))
- str_seats = ' '.join(fixed_list)
- for i in range(1, row + 1):
- print(i, str_seats)
- def main():
- row = int(input("Enter number of rows: "))
- seats = int(input("Enter a number of seats in each row: "))
- building_seats(row, seats)
- main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement