python - Again, 'return' outside function -


i'm trying write module calculates least common multiple, same error: 'return' outside function

def lcm(x,y):  amin = min(x,y)  j in range(1, amin + 1) :       if(x%j==0 , y%j==0) :            jmax = j            z= (x*y)/(jmax)       return z 

i tried indent return line, it's indented @ same level if, don't know do.

the function body needs indented:

def lcm(x,y):     amin = min(x,y)      j in range(1, amin + 1) :          if x%j==0 , y%j==0 :  # also, no need use parentheses there               jmax = j               z= (x*y)/(jmax)      return z 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -