How to create a dictionary with calculation and range in Python

1 Answer

0 votes
dic = {x ** 2 for x in range(10)}
 
print(dic)


'''
run:

{0, 1, 64, 4, 36, 9, 16, 49, 81, 25}

'''

 



answered Jul 19, 2019 by avibootz

Related questions

...