Question: IN PYTHON 3 LANGUAGE The windows generator takes an iterable and two ints (call them n and m; with ms default value 1) as parameters:

IN PYTHON 3 LANGUAGE

The windows generator takes an iterable and two ints (call them n and m; with ms default value 1) as parameters: it produces lists of n values: the first list contains the first n values; every subsequent list drops the first m from the previous list and adds the next m values from the iterable, until there are fewer than n values to put in the returned list.

call iter and next directly, and use a list that always contains n values, so it doesnt violate the conditions for using iterables

SAMPLE OUTPUT:

For example:

for i in windows('abcdefghijk', 4,2):

print(i,end='')

prints ['a','b','c','d'] ['c','d','e','f'] ['e','f','g','h'] ['g','h','i','j'].

for i in windows('abcdefghijk', 3,2):

print(i,end='')

prints ['a', 'b', 'c'], ['c', 'd', 'e'], ['e', 'f', 'g'], ['g', 'h', 'i'], ['i', 'j', 'k']

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!