Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Function to return sum of values for dictionary keys found in list
- #This is the declared dictionary
- words = {"a": 5, "b": 3, "c": 10 }
- #This is the list accepted in the function
- elements = []
- #Function definition
- def sum_of_values(words, elements):
- #loop through the values to get the sum
- sum_all = 0
- for num in words.values():
- if num in words.keys() in elements:
- sum_all += num
- print(sum_all)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement