Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why I keep getting this error? Please also help me test if my code works correctly after you fix the error. Results From Running Your

Why I keep getting this error? Please also help me test if my code works correctly after you fix the error.

image text in transcribedimage text in transcribed
Results From Running Your Instructor's Tests (50.0%) Summary: 6 cases (0 failures, 3 errors) EEE . . . ERROR: test1 (_main_. IsDiffTwoTest) TypeError: 'type' object is not subscriptable ERROR: test2 (_main_. IsDiffTwoTest) TypeError: 'type' object is not subscriptable ERROR: test3 (_main_. IsDiffTwoTest) TypeError: 'type' object is not subscriptable Ran 6 tests in 0. 002s FAILED (errors=3)Problem 2 [50 points] Design a recursive algorithm that will display whether it is possible to choose two integers from a list of integers such that the difference between the two equals a given value. Hint: You may wish to invoke another algorithm, (i.e., function), that accepts more parameters that perform the recursion. Submit a python function is_diff_two(values, diff) that take a list and the desired difference as a non-negative integer and returns true or false. Examples: is_diff_two ( [2, 4, 8], 4) # returns True is_diff_two( [1, 2, 4, 8, 1], 7) # returns True is_diff_two( [2, 4, 4, 8], 7) # returns False is_diff_two( , 7) # returns False is_diff_two ( [-1, -3,5, 8, 10], 11) #returns True

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

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions