Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14331

random positioned continuous sublist from list [closed]

$
0
0

I have a list

L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

I want to create a sublist w from L of fixed size length 4 . Start and stop are w are randomly chosen. Valid W are shown below

[1,2,3,4] [6,7,8,9][3,4,5,6][2,3,4,5]

etc.

(1) Sublist is always fixed size.(2) Sublist is made from consecutive elements from L

how this can be done in neat pythonic way ?


Viewing all articles
Browse latest Browse all 14331

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>