I'm trying to get a list of substrings of a given length out of a string.
For example, if I have a string
word = "PYTHON"
and the specified substring length is 4, how can I obtain the following list?
['PYTH', 'YTHO', 'THON']
Here is my attempt:
size = 4
win = [] 
word = "PYTHON"
i = iter(word)
for x in range(0,size):
    win.append(next(i))
print(win)
for e in i:
    win = win[1:] + [e]            
    print(win)
 
     
     
     
     
     
    