0
why this code is not working
def max(x,y,z): if x >=y and x>=z: return x else if: y>=x and y>=z: return y else: return z print(max(4, 7,5)) z = max(8, 5) print(z)
3 Answers
+ 3
def max(x,y,z):
if x >=y and x>=z:
return x
# use elif instead else
elif y>=x and y>=z:
return y
# you had bad indentation
else:
return z
print(max(4, 7,5))
#max () required 3 elements
z = max(8, 5, 0)
print(z)
+ 2
def max(x,y,z):
if x >=y and x>=z:
return x
#you must use condition in one strong "elif"
elif y>=x and y>=z:
return y
else:
return z
#just call function
max(4, 7,5)
#and then you miss one atribut
z = max(8, 5,3)
print(z)
+ 2
your max() takes three arguments. you give only two here (z = max(8, 5)).
and there's built-in function max(), why don't you use it?
#aaand elif, yes