The 'In' Operator


Im curious as to why the example has a come at the end of the "print key, d[key]," but requires you to not put one there on your code?

my_dict = {"Svilen": "Desi", 
"Borislav": "D", "Joro": "Ani"}
print my_dict.keys()
print my_dict.values()
for key in my_dict:
    print key, my_dict[key] ,

this gives the "oops looks like you didn't print out every key" error


The last comma is likely a part of the instruction text grammar, not the code sample and should be ignored. But now that we know about it, at least we know about it.

The above is a coerced, raw expression that the console does its best to display. The next level would be to explicitly convert to string format...

print "%s: %r" % (key, my_dict[key])


Well it's in the code box part of the text, so its prob a mistake. Thanks