Finding your seat on a plane is never fun, particularly for a long haul flight... You arrive, realise again just how little leg room you get, and sort of climb into the seat covered in a pile of your own stuff.

To help confuse matters (although they claim in an effort to do the opposite) many airlines omit the letters 'I' and 'J' from their seat naming system.

the naming system consists of a number (in this case between 1-60) that denotes the section of the plane where the seat is (1-20 = front, 21-40 = middle, 40+ = back). This number is followed by a letter, A-K with the exclusions mentioned above.

Letters A-C denote seats on the left cluster, D-F the middle and G-K the right.

Given a seat number, your task is to return the seat location in the following format:

'2B' would return 'Front-Left'.

If the number is over 60, or the letter is not valid, return 'No Seat!!'.

Difficulty: introductory

Starter code:

def plane_seat(a):
	

Solutions:
def plane_seat(a):
    front, middle, back = (list(range(1,21)), list(range(21,41)), list(range(41,61)))
    left, center, right = ('ABC', 'DEF', "GHK")
    x, y = ('', '')
        
    if int(a[:-1]) in front:    x = 'Front-'
    if int(a[:-1]) in middle:   x = 'Middle-'
    if int(a[:-1]) in back:     x = 'Back-'

    if a[-1] in left:    y = 'Left'
    if a[-1] in center:  y = 'Middle'
    if a[-1] in right:   y = 'Right'
    
    return x+y if all((x,y)) else 'No Seat!!'


def plane_seat(a):
    n, c = int(a[:-1]), a[-1]
    side = "Left" if c in "ABC" else "Middle" if c in "DEF" else "Right" if c in "GHK" else ""
    depth = "Front" if 0 < n < 21 else "Middle" if 20 < n < 41 else "Back" if 40 < n < 61 else ""
    return f"{depth}-{side}" if depth and side else "No Seat!!"


def plane_seat(a):
    section = ['Front','Middle','Back',None]
    cluster = {'ABC':'Left','DEF':'Middle','GHK':'Right'}
    my_section = section[((int(a[:-1])-1)//20)]
    my_cluster = [v for k,v in cluster.items() if a[-1].upper() in k]
    return "No Seat!!" if not (my_section and my_cluster) else "{}-{}".format(my_section,my_cluster[0])

def plane_seat(a):
    row = int(a[:-1])
    seat = a[-1]
    
    if row > 60 or seat not in 'ABCDEFGHK':
        return 'No Seat!!'
        
    if row <= 20:
        end = 'Front'
    elif row <= 40:
        end = 'Middle'
    else:
        end = 'Back'
        
    if seat in 'ABC':
        side = 'Left'
    elif seat in 'DEF':
        side = 'Middle'
    else:
        side = 'Right'
        
    return f'{end}-{side}'




def plane_seat(a):
    num, alpha = int(a[:-1]), a[-1]
    if num > 60 or alpha in 'IJ' or alpha > 'K':
        return 'No Seat!!'
    section = ('Front', 'Middle', 'Back')[(num > 20) + (num > 40)]
    cluster = ('Left', 'Middle', 'Right')[(alpha > 'C') + (alpha > 'F')]
    return f'{section}-{cluster}'

def plane_seat(a):
    try:
        number, letter = a[:-1], a[-1]
        number = int(number)
        if not 1<=number<=60 or not letter in 'ABCDEFGHK':
            return 'No Seat!!'
        result = []
        return '-'.join(('Front' if number<=20 else 'Middle' if number<=40 else 'Back',
                        'Left' if letter in 'ABC' else 'Middle' if letter in 'DEF' else 'Right'))
    except:
        return 'No Seat!!'
            


CLUSTERS = {
    'A': 'Left',
    'B': 'Left',
    'C': 'Left',
    'D': 'Middle',
    'E': 'Middle',
    'F': 'Middle',
    'G': 'Right',
    'H': 'Right',
    'K': 'Right',
}

def plane_seat(a):
    row = int(a[:-1])
    col = a[-1:]
    section = (
        'Front' if row <= 20 else
        'Middle' if row <= 40 else
        'Back' if row <= 60 else
        ''
    )
    cluster = CLUSTERS.get(col)
    if section and cluster:
        return f'{section}-{cluster}'
    else:
        return 'No Seat!!'

def plane_seat(a):
    n , l = int(a[:-1]), a[-1]
    if n > 60 or l not in "ABCDEFGHK": return "No Seat!!"
    n = 'Front' if n < 21 else 'Middle' if n < 40 else 'Back'
    l = "Left" if l < "D" else "Middle" if l < "G" else "Right"
    return "{}-{}".format(n,l)

# import this
# Явное лучше, чем неявное.
# Простое лучше, чем сложное.
# Если реализацию легко объяснить — идея, возможно, хороша.
def plane_seat(a):
    num2 = a[0] + a[1]
    num1 = a[0]
    let = a[-1]
    if let == 'I' or let == 'J':
        return ('No Seat!!')
    elif len(a) == 3:
        if int(num2) > 60:
            return ('No Seat!!')
        elif int(num2) >= 1 and int(num2) <= 20:
            if let == 'A' or let == 'B' or let == 'C':
                return ('Front-Left')
            if let == 'D' or let == 'E' or let == 'F':
                return ('Front-Middle')
            if let == 'G' or let == 'H' or let == 'K':
                return ('Front-Right')   
        elif int(num2) >= 21 and int(num2) <= 40:
            if let == 'A' or let == 'B' or let == 'C':
                return ('Middle-Left')
            if let == 'D' or let == 'E' or let == 'F':
                return ('Middle-Middle')
            if let == 'G' or let == 'H' or let == 'K':
                return ('Middle-Right')
        elif int(num2) >= 41 and int(num2) <= 60:
            if let == 'A' or let == 'B' or let == 'C':
                return ('Back-Left')
            if let == 'D' or let == 'E' or let == 'F':
                return ('Back-Middle')
            if let == 'G' or let == 'H' or let == 'K':
                return ('Back-Right')            
    elif len(a) == 2:
        if int(num1) >= 1 and int(num1) <= 20:
            if let == 'A' or let == 'B' or let == 'C':
                return ('Front-Left')
            if let == 'D' or let == 'E' or let == 'F':
                return ('Front-Middle')
            if let == 'G' or let == 'H' or let == 'K':
                return ('Front-Right')   
                 
'''    
1-20 - front
21-40 - middle
41-60 - back

A,B,C - left
D,E,F - middle
G,H,K - right
'''



# What do you mean computationally wasteful?
def plane_seat(a):
    return {
        f'{row}{seat}': f'{end}-{side}'
        for end, rows in [('Front', list(range(1, 21))), ('Middle', list(range(21, 41))), ('Back', list(range(41, 61)))]
        for row in rows
        for side, seats in [('Left', 'ABC'), ('Middle', 'DEF'), ('Right', 'GHK')]
        for seat in seats
    }.get(a, 'No Seat!!')