Question: Write a function called insert_name_here that takes as argument a list of integers (we'll call this list vals) and returns a list containing each

Write a function called insert_name_here that takes as argument a list of integers (we'll call this list >>> insert_name_here ([2,5,8,3]) [8] >>> insert_name_here ([-1,1,0,5]) [1, 5] >>> insert_name_here

Write a function called insert_name_here that takes as argument a list of integers (we'll call this list vals) and returns a list containing each integer in vals that is greater than the integers immediately before and after it. In the case of the first element of vals, it only needs to be greater than the element after it to be included. In the case of the last element of vals, it only needs to be greater than the element before it to be included. If vals is empty or only contains one element, then insert_name_here () should return an empty list. Below are examples of how your function should behave. >>> insert _name_here ([2,5,8,3]) [8] >>> insert_name_here ([-1,1,0,5]) [1, 5] >>> insert_name_here ([3,2,2,4]) [3, 4] >>> insert _name_here ([3,2,2,3]) [3, 3] >>> insert_name_here ([10,8, -3,70,15,22,20,19,-5]) [10, 70, 22] >>> insert _name_here ([200, 100, 300, 450, 570, 100, 120]) [200, 570, 120]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

python def findpeaksvals peaks for i in rangelenvals if i 0 or i 0 and valsi valsi 1 and i lenvals 1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!