7

I was modifying a dictionary, and accidentally wrote something like

data = dict(a=1, b=2)
if condition:
    data['c']: 3

I expected this to be a syntax error, however it runs correctly, and the statement simply seems to have no effect.

Which makes me curious: what kind of statement is this, and why is this legal?

blue_note
  • 25,410
  • 6
  • 56
  • 79

0 Answers0