Getting syntax error on else, what is wrong?


#1




def distance_from_zero(n):
    if type(n) == int or type (n) == float:
        return abs(n)
        else:
            return "Nope"


#2

else should be at the same indent level as if, so you have if/else


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.