/
๐Ÿ

comprehensions in dictionary

python

how to use comprehensions in dictionary

python
values = {x:x*2 for x in range(5)}
print(values)
Output
{0 : 0, 1 : 2, 2 : 4, 3 : 6, 4 : 8}
Edit this page
logo
Hi Mohsen save your notes