Hello guys!
I have a list of words in a variable called stems
. I need to write a for loop which will print 5 words in every window. (i.e. The window width is 5 words)
stems: List = [
'stem1','stem2','stem3','stem4','stem5',
'stem6','stem7','stem8','stem9','stem10'
and more...
]
Output should be:
0 [‘stem1’, ‘stem2’, ‘stem3’, ‘stem4’, ‘stem5’]
1 [‘stem6’, ‘stem7’, ‘stem8’, ‘stem9’, ‘stem10’]
2 [‘stem11’, ‘stem12’, ‘stem13’, ‘stem14’, ‘stem15’]
3 [‘stem16’, ‘stem17’, ‘stem18’, ‘stem19’, ‘stem20’]
The code that I have now (doesn’t work properly)
n = 100
for i in range(len(stems)-n):
print(i, stems[i:5])