How to create list of a list using list comprehension in Python

1 Answer

0 votes
lst = [1, 2, 3, 4]

lst_lst = [[x**2, x**3] for x in lst]

print(lst_lst) 



'''
run:

[[1, 1], [4, 8], [9, 27], [16, 64]]
 
'''

 



answered Jul 24, 2019 by avibootz
...