Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1. byrja spurja notanda um row og colum
- def seat_to_letter(seats):
- list_seats = []
- if seats == 2:
- list_seats.append("A")
- list_seats.append("B")
- if seats == 4:
- list_seats.append("A")
- list_seats.append("B")
- list_seats.append("C")
- list_seats.append("D")
- if seats == 6:
- list_seats.append("A")
- list_seats.append("B")
- list_seats.append("C")
- list_seats.append("D")
- list_seats.append("E")
- list_seats.append("F")
- return list_seats
- def inp_to_dict(row, list_seats):
- my_dict = {}
- for i in range(1, row+1):
- my_dict[i] = list_seats
- return my_dict
- def print_rows(my_dict):
- seat_lenght = len(my_dict[1])
- counter = 0
- print(my_dict)
- #for attribute, value in my_dict.items():
- #print('{} : {}'.format(attribute, value))
- def replace_seat(my_dict, book_seat):
- my_list = []
- replace_list = []
- my_list.append(book_seat)
- for i in my_list:
- row, seat = i.split(" ")
- replace_list.append((row, seat))
- x = replace_list[0][0]
- y = replace_list[0][1]
- if int(x) in my_dict.keys():
- if y in [x for v in my_dict.values() for x in v]:
- my_dict[int(x)] = [s.replace(y, 'X') for s in my_dict[int(x)]]
- print_rows(my_dict)
- else:
- print("Seat number is invalid!")
- return my_dict
- def seat_taken(my_dict, book_seat):
- pass
- def main():
- loop = True
- row = int(input("Enter number of rows: "))
- seats = int(input("Enter number of seats in each row: "))
- while loop:
- list_seats = seat_to_letter(seats)
- seat_to_letter(seats)
- inp_to_dict(row, list_seats)
- my_dict = inp_to_dict(row, list_seats)
- print_rows(my_dict)
- book_seat = input("Input seat number (row seat): ")
- replace_seat(my_dict, book_seat)
- more = input("More seats (y/n)?")
- if more == "n":
- loop = False
- else:
- book_seat = input("Input seat number (row seat): ")
- replace_seat(my_dict, book_seat)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement