So I currently have a function that outputs sound barrier for the input height.
def soundbarier (y):   
    if 0 < y < 1524:
        S = 340.3
    elif 1524 < y < 3048:
        S = 334.4
    elif 3048 < y < 4572:
        S = 328.4
    elif 4572 < y < 6096:
        S = 322.2
    elif 6096 < y < 7620:
        S = 316.0
    elif 7620 < y < 9144:
        S = 309.6
    elif 9144 < y < 10668:
        S = 303.6
    elif 10668 < y < 12192:
        S = 295.4
    else:
        S = 294.5
    return (float(S))
I want to shorten it using a dictionary but I can't get it to work.
def SOUND(y):
    return {
    0 < float(y) < 1524: 340.3,
    1524 < y < 3048: 334.4,
    3048 < y < 4572: 328.4,
    4572 < y < 6096: 322.2,
    6096 < y < 7620: 316.0,
    7620 < y < 9144: 309.6,
    9144 < y < 10668: 303.6,
    10668 < y < 12192: 295.4
    }.get(y, 9)
print(SOUND(1500))
I don't really want any default values. How could I make it work? I basically need the function to output S for a certain Y within a range.
 
     
     
     
    