Header Ads

Responsive Ads Here

Dictionary Comprehension

 Dictionary Comprehension



d = {1:1, 2:8, 3:27}

d1 = {}
for i in range(1,11):
    d1[i] = i ** 3
print(d1)

d2 = {i:i ** 3 for i in range(1,11)}
print(d2)

Powered by Blogger.