12. Changing your mind - Can you execute two deletions on the same line?


12. Changing your mind

I'm not stuck on the lesson. I was able to successfully complete it. However, I first attempted to delete both the sloth and the Bengal tiger on the same line, as in

del zoo_animals['Sloth', 'Bengal Tiger']

and I get an error message.

Is it possible to delete (or add, for that matter) multiple items from a dictionary with one line of text? Again, I completed the lesson correctly by issuing two separate delete commands. Just curious if what I attempted is possible if I had used a different syntax. Thanks!


You can do this: del dict[key1],dict[key2] :slight_smile:


Ah, thank you! That makes a lot of sense.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.