Skip to content

Instantly share code, notes, and snippets.

Created July 28, 2020 21:20
What would you like to do?
from typing import Dict, List, Tuple
def makeKeyDict(items:List[Tuple]) -> Dict:
"Gives a list of tuples (a,b), returns a dict mapping a to set of b"
d = {}
for (a,b) in items:
d[a] = set([b]).union(d.get(a,set()))
return d
def findKeysWithMultipleValues(keydict) -> List:
ks = []
for (k,v) in keydict.items():
if len(v) > 1:
return ks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment