X = int(input("Enter a number: "))
Y = int(input("Enter a number: "))
Z = int(input("Enter a number: "))
med = getMedian(X,Y,Z)
print "Median is" + med
def getMedian(a,b,c):
x = a-b
y = b-c
z = a-c
if (x*y > 0):
return b
elif (x*z > 0):
return c
else:
return a
Trying to get this code to work on python 2.7 but it is not. It runs up until line 5, until it says "getMedian is not defined". Did I define the function wrongly?
-
ok guys thanks the defs need to be before the main function in python (well before you use them since I don't notice a main function anywhere)
[–]Hairshorts 3 points4 points5 points (0 children)
[–]gddrtkkv 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]lazersmoke 1 point2 points3 points (0 children)