0
hy. When i run this code on shell it gives me an error of unindent does not match any outer indentation level....how to handle t
def max(x, y): if x>y: return x else: return y print(max(7, 9)) grt=max(x, y) print (grt)
2 Answers
+ 5
@Kyle Broflovski is right for last two lines, but block inside the function is indented ( of only once space before the if )...
Unfortualy, in the question author version, the print() line is also indented with one space, so it's considered as in the function block :P
So, @Kyle solution is ok for fix the indentation error, but anyway, the line:
grt=max(x, y)
... will throw an undeclared variable error ( unless some values were assigned to 'x' and 'y' somewhere before in a part of code not provided ^^ )
+ 2
your grt and print at the bottom are indented and your if statement inside your function isn't. inside if/else get 4 space indent.. inside function also get 4 space indent.
def max(x, y):
if x>y:
return x
else:
return y
print(max(7, 9))
grt=max(x, y)
print (grt)