I keep getting return outside of function

list_a = ['mov a 5','inc a','dec a','dec a','jnz a -1','inc a'] 
m = 'm'

for string in list_a:
    if m in string.split():
        return True

Error code comes back and says the last line is outside of the function. I don’t know why

return can only be written inside a function.

def string_in_list(a, m):
    for string in a:
        if m in string.split():
            return True
    return False
>>> def make_dict(a, v):
	return {a: v}

>>> make_dict('a', 5)
{'a': 5}
>>> 
1 Like