Question: python def drop(nums, n): return None if __name__ == '__main__' : nums = [0, 1, 2, 3, 4, 5, 6, 7, 8] n = 3
python

def drop(nums, n): return None
if __name__ == '__main__':
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8] n = 3 print('Testing drop for nums = ' + str(nums) + ', n = ' + str(n) + ': ' + str(drop(nums, n))) nums = [2, 4, 6, 8, 10, 12, 14] n = 2 print('Testing drop for nums = ' + str(nums) + ', n = ' + str(n) + ': ' + str(drop(nums, n))) nums = [8, 6, 7] n = 4 print('Testing drop for nums = ' + str(nums) + ', n = ' + str(n) + ': ' + str(drop(nums, n))) Part II: Drop Every n-th Element (2 points) Write a recursive function drop that takes a non-empty list of integers and a positive integer n as its argu ments, and returns a new list formed by dropping every n-th item from the original list. You may assume that n 1. Your function must be recursive and must not use any loops. Examples: Function Call Return Value drop ([0, 1, 2, 3, 4, 5, 6, 7, 8] 3) 0 1, 3, 4, 6, 7] drop (12, 4, 6, 8, 10, 12, 141, 2) [2, 6, 10, 14 drop 8 6, 71, 4) [8, 6, 7]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
