Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #liljas17@ru.is and stefana19@ru.is
- SPACE = ' '
- def get_num_rows():
- '''Prompts user for numbers of rows '''
- num_rows = int(input('Enter number of rows: '))
- return num_rows
- def get_num_seats():
- ''' Prompts user asking how many seats in each row '''
- num_seats = int(input('Enter number of seats in each row: '))
- return num_seats
- def get_seating(rows, seats):
- ''' Creates seating arrangement with single alphabet character for each seat '''
- seating =[]
- for i in range(rows):
- all_rows = []
- for j in range(65, 90):
- seat = chr(j)
- all_rows.append(seat)
- seating.append(all_rows)
- return seating
- def print_seating(rows, seats, seating):
- '''
- Prints out the seating arrangement in accordance with the number of rows and seats per row
- We created the constant SPACE as a single space, simply because it's easier to see and
- troubleshoot for exact spacing in Mimir
- '''
- seating_num = 0
- for i in range(rows):
- seating_num += 1
- print('{:>2}{}'.format(seating_num, SPACE*3), end = '')
- for j in range(seats):
- seats_l = seating[i][j]
- print('{:}{}'.format(SPACE, seats_l), end = '')
- for j in range(seats, seats + 1):
- print(end = ' ')
- for j in range(seats, seats * 2):
- seats_r = seating[i][j]
- print('{:}{}'.format(SPACE, seats_r), end = '')
- print()
- def choose_seat(seating):
- ''' Prompts the user for a seat to reserve on the plane. This function is unfinished '''
- input_choice = input('Input seat number (row seat): ')
- seat_choice = input_choice.split()
- if seat_choice != seating:
- print('Seat number is invalid!')
- elif seat_choice == 'X':
- print('That seat is taken!')
- else:
- print()
- return seat_choice
- def main():
- rows = get_num_rows()
- seats = get_num_seats()
- org_seating = get_seating(rows, seats)
- print_seating(rows, seats, org_seating)
- #seat_choice = choose_seat(org_seating)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement