While iterating over dictionary, remove elements not required and move further in dictionary(Python) -
my concern here if name_3[0]>50, add html table , if name_3[0]<=50, discard , iterate next value in dictionary because don't want add entry below 50. below logic think of. can iterate through next value ?
for name_1 in sorted(any_dictionary.keys()): name_2 in sorted(any_dictionary[name_1].keys()): name_3 in any_dictionary[name_1][name_2]: if (name_3[0] > 50): size_kb = name_3[0] address=name_3[1] html += """<tr> <td>{}</td> <td>{}</td> <td>{:,}</td> <td>{:,} [{}]</td> <td>{}</td> </tr>\n""".format(name_1, name_2, size_kb, name_3[2], name_3[3], address)
as far know, never idea change dictionary (or list or set) while iterating on it.
maybe add values, want keep, in new dictionary instead?
Comments
Post a Comment