Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get portion of dictionary

a_dictionary = {"a": 1, "b": 2, "c": 3, "d": 4}

a_subset = {key: value for key, value in a_dictionary.items() if value > 2}

print(a_subset)

# Output:
# {'c': 3, 'd': 4}
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #python #portion #dictionary
ADD COMMENT
Topic
Name
2+9 =