fork download
  1. x = 3
  2.  
  3. lista = ['1','2','3','4','5','6','7','8','9']
  4.  
  5. for i in lista[2:9] :
  6. final_list= lambda test_list, x : [test_list[i:i+x] for i in range(0, len(lista), x)]
  7. output=final_list(lista, x)
  8. print(output)
  9. lista.pop(0)
Success #stdin #stdout 0.03s 9256KB
stdin
Standard input is empty
stdout
[['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]
[['2', '3', '4'], ['5', '6', '7'], ['8', '9']]
[['3', '4', '5'], ['6', '7', '8'], ['9']]
[['4', '5', '6'], ['7', '8', '9']]
[['5', '6', '7'], ['8', '9']]
[['6', '7', '8'], ['9']]
[['7', '8', '9']]