Question
IN PYTHON 3 LANGUAGE DO NOT USE FOR LOOPS! call iter and next directly , and use a list that always contains n values, so
IN PYTHON 3 LANGUAGE
DO NOT USE FOR LOOPS!
call iter and next directly, and use a list that always contains n values, so it doesnt violate the conditions for using iterables
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started