Question: How can I Write a function called largest that takes a list of integers as argument. It Recursively returns the largest integer of the list.
How can I Write a function called largest that takes a list of integers as argument. It Recursively returns the largest integer of the list. Name of the file: largest.py (Python). I am having issues understanding how to add a recursive into the function, help also with the recursive.
Here are few sample runs given:
>>> largest( [1,12,4,10])
12
>>> Largest([])
Traceback (most recent call last):
File ..
print(Largest([]))
File ..
raise ValueError('Please provide a non empty list')
ValueError: Please provide a non empty list
>>>Largest([1,2.2])
Traceback (most recent call last):
File xxxxx
print(Largest([1,2.2]))
File xxxxx
raise TypeError('the passed argument is not an array')
TypeError: the passed argument is not an array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
