Question: USE PYTHON3; DO NOT IMPORT PACKAGES if you feel that the below function will be useful may use it Write a function that takes in
USE PYTHON3; DO NOT IMPORT PACKAGES

if you feel that the below function will be useful may use it

Write a function that takes in an iterable object and returns a list of its values, skipping values in between by an increasing amount (starting with 0, increment by 1 once collected a value). The function returns the output values as a list once the input has no more items, or we reach k elements in our output list. You cannot convert the input back to its original type. Example: The number of elements skipped starts at 0, then increases by 1 each time >>> skip_increasing(iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 5)) 1 -> 2 (0 elements skipped) 2-> 4 (1 element skipped) 4- -> 7 (2 elements skipped) 7 -> 11 (3 elements skipped) Returns (1, 2, 4, 7, 11] Hints: (1) The next() function will be helpful to skip elements. Recall from question 5 that next() has an optional second argument called default, which might be helpful depending on your implementation. You can repeat calling this function with another loop to skip multiple elements in a row. (2) You may want to keep track of the number of elements you want to skip for your next hop while traversing through the iterable. (3) Also, you may want to keep track of the length of your output list in your loop, so that you can decide when to break the loop, if needed. def skip_increasing (input, k): >>> skip_increasing(iter([1,2,3,4,5,6,7,8,9,10,11]), 5) [1, 2, 4, 7, 11] >>> skip_increasing(iter('ABcDefGhijklmnopqrs'), 10) ['A', 'B', 'D', 'G', 'K', 'P'] >>>> skip_increasing (iter((1, None, 3, 4, 5, 6, 7, 8)), 3) [1, None, 4] # YOUR CODE GOES HERE # def is_iterable(obj): A function that checks if obj is a iterable (can be iterated over in a for-loop). DO NOT MODIFY THIS FUNCTION. You don't need to add new doctests for this function. >>> is_iterable(1) False >>> is_iterable("DSC_20") True >>> is_iterable(["Fall", 2020]) True try: iter(obj) return True except TypeError: return false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
