SHARE
TWEET

Untitled

a guest Oct 13th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 1. byrja spurja notanda um row og colum
  2.  
  3.  
  4. def seat_to_letter(seats):
  5.     list_seats = []
  6.     if seats == 2:
  7.         list_seats.append("A")
  8.         list_seats.append("B")
  9.     if seats == 4:
  10.         list_seats.append("A")
  11.         list_seats.append("B")
  12.         list_seats.append("C")
  13.         list_seats.append("D")
  14.     if seats == 6:
  15.         list_seats.append("A")
  16.         list_seats.append("B")
  17.         list_seats.append("C")
  18.         list_seats.append("D")
  19.         list_seats.append("E")
  20.         list_seats.append("F")
  21.     return list_seats
  22.  
  23. def inp_to_dict(row, list_seats):
  24.     my_dict = {}
  25.     for i in range(1, row+1):
  26.         my_dict[i] = list_seats
  27.     return my_dict
  28.  
  29. def print_rows(my_dict):
  30.     seat_lenght = len(my_dict[1])
  31.     counter = 0
  32.     print(my_dict)
  33.     #for attribute, value in my_dict.items():
  34.         #print('{} : {}'.format(attribute, value))
  35.  
  36. def replace_seat(my_dict, book_seat):
  37.     my_list = []
  38.     replace_list = []
  39.     my_list.append(book_seat)
  40.     for i in my_list:
  41.         row, seat = i.split(" ")
  42.         replace_list.append((row, seat))
  43.     x = replace_list[0][0]
  44.     y = replace_list[0][1]
  45.     if int(x) in my_dict.keys():
  46.         if y in [x for v in my_dict.values() for x in v]:
  47.             my_dict[int(x)] = [s.replace(y, 'X') for s in my_dict[int(x)]]
  48.             print_rows(my_dict)
  49.     else:
  50.         print("Seat number is invalid!")
  51.     return my_dict
  52.  
  53.  
  54. def seat_taken(my_dict, book_seat):
  55.     pass
  56.  
  57.  
  58. def main():
  59.     loop = True
  60.     row = int(input("Enter number of rows: "))
  61.     seats = int(input("Enter number of seats in each row: "))
  62.     while loop:
  63.         list_seats = seat_to_letter(seats)
  64.         seat_to_letter(seats)
  65.         inp_to_dict(row, list_seats)
  66.         my_dict = inp_to_dict(row, list_seats)
  67.         print_rows(my_dict)
  68.         book_seat = input("Input seat number (row seat): ")
  69.         replace_seat(my_dict, book_seat)
  70.         more = input("More seats (y/n)?")
  71.         if more == "n":
  72.             loop = False
  73.         else:
  74.             book_seat = input("Input seat number (row seat): ")
  75.             replace_seat(my_dict, book_seat)
  76.  
  77.  
  78.  
  79. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top