Advertisement
Dammiejoy20

Untitled

Mar 8th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #This is a function to return elements common to both keys and values in a dictionary in a list
  2.  
  3. #The declared dictionary
  4. elements = {
  5.     "A": "K",
  6.     "B": "D",
  7.     "C": "A",
  8.     "D": "Z"
  9. }
  10. #Function definition
  11. def common_elements(elements):
  12. #loop through the values and return the elements in a list
  13.     for num in elements.items():
  14.         if num in elements.keys() and num in elements.values():
  15.             print(list(num))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement