Assignment in python for loop possible?
- by flyingcrab
I have a dictionary d (and a seperate sorted list of keys, keys). I wanted the loop to only process entries where the value is False - so i tried the following:
for key in keys and not d[key]:
#do foo
I suppose my understanding of python sytax is not what i thought it was - because the assignment doesnt suppose to have happened above, and a i get an instanciation error.
The below works of course, but I'd really like to be able to use something like the code above.. possible?
for key in keys:
if d[key]: continue
#foo time!
Thanks!