Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python set and dictionary comprehensions

simple_dict = {
    'a': 1,
    'b': 2
}
my_dict = {key: value**2 for key,value in simple_dict.items()}
print(my_dict)
#result = {'a': 1, 'b': 4}
Source by www.datacamp.com #
 
PREVIOUS NEXT
Tagged: #python #set #dictionary #comprehensions
ADD COMMENT
Topic
Name
7+5 =