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)

2nd Aug 2016, 6:19 AM
LALIT JAIN
LALIT JAIN - avatar
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)
2nd Aug 2016, 6:52 AM
‫Ido Tal
‫Ido Tal - avatar
+ 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)
2nd Aug 2016, 6:32 AM
Pavel
Pavel - avatar
+ 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
2nd Aug 2016, 6:32 AM
aruluth
aruluth - avatar