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
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