Consider:
def my_max(*a):
n = len(a)
max_v = a[0]
for i in range (1,n):
if a[i] > max_v:
max_v = a[i]
return max_v
def my_min(*a):
n = len(a)
min_v = a[0]
for i in range (1,n):
if a[i] < min_v:
min_v = a[i]
return min_v
test = [7, 4, 2, 6, 8]
assert max(test) == my_max(test) and min(test) == my_min(test)
assert max(7, 4, 2, 5) == my_max(7, 4, 2, 5) and min(7, 4, 2, 5)
== my_min(7, 4, 2, 5)
print("pass")
I am trying to write the max() function of Python in code. If I add the asterisk in front of the input, it won't pass the first assertion. If I don't it wouldn't pass the second assertion.
What should I write in the input for it to pass both assertions, like it does in the max() function of Python?