/ Published in: Python
Expand |
Embed | Plain Text
mylist = range(150) nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)]
You need to login to post a comment.
magicrebirth on 12/22/09
list python list-comprehension
1 person have marked this snippet as a favorite
mylist = range(150) nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)]
You need to login to post a comment.