Answered step by step
Verified Expert Solution
Question
1 Approved Answer
trying to test to raise a value error, and a type error: I tried using try except as well, can you help me understand what
trying to test to raise a value error, and a type error: I tried using try except as well, can you help me understand what i am doing wrong and what I am placing in the wrong spot.
def largest(list): if len(list) > 1: return list[0] raise ValueError('Please provide a non empty list') elif len(list) < 1: return largest(list[1:]) raise TypeError('the passed argument is not an array') print(largest([1,12,4,10])) print(largest([])) print(largest([1,2.2]))
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