Practice makes perfect syntax error


#1



https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096


The code seems right but it just keeps saying the last character of "return" is invalid
File "python", line 6
else return False
^
SyntaxError: invalid syntax


def cube(n):
    return n ** 3
def by_three(n):
    if n % 3 == 0:
        return cube(n)
    else return False


#2

def cube(n):
return n ** 3

def by_three(n):
if (n%3==0):
return cube(n)
else:
return False


#3

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