Question: PYTHON 2. Write a function doubles that takes as a list of integers as a parameter and returns a list that contains all values in

PYTHON

2. Write a function doubles that takes as a list of integers as a parameter and returns a list that contains all values in the given list that are exactly twice the previous value in the list. If the list is empty or there are no values that are double the value of their predecessor, then the function returns an empty list. The list provided as a parameter should not be changed. Note that the first item in the list will never be printed since it does not have a predecessor in the list. Sample usage: >>> doubles( [4,8,-12,-24,48,3,6,12,24,2]) [8, -24, 6, 12, 24] >>> doubles([1,2,3,4,5]) [2] >>> doubles([]) [] >>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!