recursive dict comprehension
I am building out a complex dictionary with some unconventional code. I'm
just curious if there is some way to check the current dictionary's value
or even the current list's values while building it out as to avoid
duplicates/unwanted values. Here is the code I have:
locations = {words[i]: map(lambda x: words[x::].index(words[i]) if
words[i] in words[x::] and words[x::].index(words[i]) not in
self[words[i]] else None, range(len(words))) for i in range(len(words))}
# the important part here is
and words[x::].index(words[i]) not in self[words[i]]
Is anything like the above possible without for/while iteration?
No comments:
Post a Comment