Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is a function to return elements common to both keys and values in a dictionary in a list
- #The declared dictionary
- elements = {
- "A": "K",
- "B": "D",
- "C": "A",
- "D": "Z"
- }
- #Function definition
- def common_elements(elements):
- #loop through the values and return the elements in a list
- for num in elements.items():
- if num in elements.keys() and num in elements.values():
- print(list(num))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement