I am looking for the answer to the same question found here:
Python - Find the greatest number in a set of numbers
However, I would like to build my own program instead of using the built-in function max()
. This is what I have right now, but it's throwing an error, I think because of variable scope.
def two_of_three(a, b, c):
if a>=b:
x=a
else:
x=b
if b>=c:
y=b
else:
y=c
if a>=c:
x=a
else:
x=c
return x**x+y**y
assert two_of_three(3,4,5)==41
assert two_of_three(0,1,2)==5
assert two_of_three(9,21,89)==8362
Here is the error I am getting:
Traceback (most recent call last):
File "python_hw1.py", line 32, in <module>
assert two_of_three(3,4,5)==41
AssertionError