Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Can anyone be trained to be a project manager?

Answered: 1 week ago

Question

What is the relationship between humans?

Answered: 1 week ago

Question

What is the orientation toward time?

Answered: 1 week ago