Add dictionary to a list

PHOTO EMBED

Wed Nov 09 2022 05:38:56 GMT+0000 (Coordinated Universal Time)

Saved by @hasib404 #python

l = [dict(zip([1],[x])) for x in range(1,3)]
print(l)


# Output
#[{1: 1}, {1: 2}]
content_copyCOPY

https://www.geeksforgeeks.org/appending-a-dictionary-to-a-list-in-python/