Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import string
  2. import copy
  3. def building_seats(row, seats):
  4. seats_list = []
  5. row_list = []
  6. alpha_list = []
  7. alpha_list = [chr(x) for x in range(ord('A'), ord('Z') + 1)]
  8. for s in alpha_list[0:seats]:
  9. seats_list.append(s)
  10. str_seats = ' '.join(seats_list)
  11. for i in range(1, row + 1):
  12. row_list.append(i)
  13. print(i, str_seats)
  14. seats_list = [seats_list]*seats
  15. reservering_seat(seats_list, row)
  16.  
  17. def reservering_seat(seats_list, row):
  18. row2, reserved_seat = input("Input seat number (row seat): ").split()
  19. row3 = int(row2)
  20. seats_list_copy = copy.deepcopy(seats_list)
  21. for index, value in enumerate(seats_list_copy[row3]):
  22. if value == reserved_seat:
  23. seats_list_copy[[row3][index]].remove(value)
  24. seats_list_copy[[row3][index]].insert(index, "X")
  25. print(seats_list_copy)
  26. printing_updated_seats(seats_list_copy, row)
  27.  
  28. def printing_updated_seats(seats_list_copy, row):
  29. fixed_list = [val for sublist in seats_list_copy for val in sublist]
  30. fixed_list = list(dict.fromkeys(fixed_list))
  31. str_seats = ' '.join(fixed_list)
  32. for i in range(1, row + 1):
  33. print(i, str_seats)
  34.  
  35.  
  36.  
  37.  
  38.  
  39. def main():
  40. row = int(input("Enter number of rows: "))
  41. seats = int(input("Enter a number of seats in each row: "))
  42. building_seats(row, seats)
  43. main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement