Question
4.Largest List Item Design a function that accepts a list as an argument and returns the largest value in the list. The function should use
4.Largest List Item
Design a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item.
This is the code I got so far. I am just stuck on the else statement
if you could add comments to the else statement so i understand what is going to be written there I would appreciate it. thank you
#Design a function that accepts a list as an argument and returns the largest #value in the list. The function should use recursion to find the largest item.
def main1(): #ask the user for a list list = [1, 5, 6, 7, 3, 9, 2, 15, 20, 2] print(get_lrg_value(list)) def get_lrg_value(list): if len(list) == 1: return list[0] else: main1()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started