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


#1




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!


#2

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


#3

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


#4

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