• Please Help..Return is frustrating me

Question related to mission The Ship Teams


Hello, When testing the two_teams using print it works as I hoped. Two sorted lists are printed I am most certainly missing something in my knowledge concening functions; when I try it as a function I get SyntaxError: 'return' outside function (<MYCODE>, line 15) ?, ? No matter where I put the return and even without arguments. Would somebody please be so kind as to help me fill the gap in my knowledge and show me where i am going wrong.

def two_teams(sailors):
    sailors ={'Smith': 34,'Wesson': 22,'Coleman': 45,'davies' : 50,'Abrahams': 19, 'Toms': 23}
    firstShip =[]
    secondShip = []
    for i in sailors.keys():
        if sailors[i] > 40 or sailors[i] < 20:


    # print(firstShip)
    # print(SecondShip)

    return [