Home > other >  The for loop.
The for loop.

Time:03-03

A=,7,2,8,9 [3]

Hope that through the for such results (int) :

[3, 3, 7,,7,2 [3], [3,7,2,8], [3,7,2,8,9]]

Or

,21,42,336,3024 [3]

thank you

CodePudding user response:

 x=[a [: I + 1] for I in range (len) (a)] 

CodePudding user response:

[a [: index + 1] for the index, I enumerate in (a)]
[[3], [3, 7], [3, 7, 2], [3, 7, 2, 8], [3, 7, 2, 8, 9]]
  • Related