[Solved] Deleting an item in dict while looping


Skip printing empty elements

Add a conditional to your code to only print elements that have content, e.g. as below.

if var:
  print(var)

(Empty dict’s evaluate to False in python conditionals).

1

solved Deleting an item in dict while looping