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

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!