How to create nested list using list comprehension in Python

1 Answer

0 votes
lst = [[i, j] for i in range(4) for j in range(i)]

print(lst) 

 
'''
run:

[[1, 0], [2, 0], [2, 1], [3, 0], [3, 1], [3, 2]]
 
'''

 



answered Jul 23, 2019 by avibootz
...