Question: Using python construct a function that takens a list of numbers and returns another list of the ranges contained in the original list. Take as
Using python construct a function that takens a list of numbers and returns another list of the ranges contained in the original list. Take as an example the list [6, 5, 13, 9, 12, 4]. This contains all the numbers from 4 to 6, it contains the number 9 and it contains all the numbers from 12 to 13. Noting that the range constructor in Python is inclusive in its first parameter and exclusive in its second parameter, the function should return [range(4, 7), 9, range(12, 14)] for the above input.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
