Why isn't this code working how I want it to?
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Sat Oct 12 05:50:16 EDT 2013
reubennottage at gmail.com writes:
> [...] The following doesn't work.
>
> for fillempt in testdict:
> if fillempt == 'filled':
> print(testdict[fillempt])
This is equivalent to
for fillempt in testdict:
if fillempt == 'filled':
print(testdict['filled'])
which in turn can be optimized to
if 'filled' in testdict:
print(testdict['filled'])
without knowing anything of the contents of tesdict.
More information about the Python-list
mailing list