Boolean as key in dictionary is causing weird problems?

Viewed 333

I am new to Python and I am currently learning about dictionaries. I was putting random values and types in a dictionary. Here is what is confusing me:

stuff = {True: 1234, 1: 2}
print(stuff[True])
print(len(stuff))

When you run this bit of code, the output is:

2
1

How is this the output? Shouldn't print(stuff[True]) be outputting 1234 and print(len(stuff)) be outputting 2? I might be missing something really obvious, but can someone please explain what is going on?

1 Answers
Related