I wonder how dict(zip(keys, values)) works
To solve Cipher Crossword, I've defined the following class inherited UserDict, and tried to find a mapping in all possible combinations of numbers and letters in checkio.
class ConsistentDict(collections.UserDict): def __setitem__(self, key, item): if not key in self.keys(): self.data[key] = item elif self[key] != item: raise ValueError #prohibit updates def checkio(words): for letters in permutations(words): try: cdict = ConsistentDict(zip(numbers, letters)) except ValueError: continue
I wanted to use dict, but ConsistentDict inherited dict didn't work in my code.
I'm just wondering that dict's behavior (when argument is zip) is defferent from UserDict's.