简体   繁体   中英

Python: Create multiple lists with increasing size

How would you create multiple lists populated with random numbers on bigger from previous preferably using list comprehension.

Example:

create 3 lists

list_1=[47]
list_2=[56,76]
list_3=[754,45,43]
 import random
 [[random.randint(1, 1000) for _ in range(list_size)] for list_size in range(1,4)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM