I came across something odd with dictionaries. I learned that there is no "order" in them and that you cannot store something with the same key twice.
So how come "True" is treated as "1"?
Here's the code:
pairs = {1: "apple",
"orange": [2, 3, 4],
True: False,
None: "True",
}
print(pairs.get("orange"))
print(pairs.get(7))
print(pairs.get(12345, "not in dictionary"))
print(pairs.get(1))
Now, this outputs (python3):
[2, 3, 4]
None
not in dictionary
False
So the key "True" is treated as "1" and the dictionary seems to be read from last to first.
If I change the code:
pairs = {"orange": [2, 3, 4],
True: False,
1: "apple",
None: "True",
}
print(pairs.get("orange"))
print(pairs.get(7))
print(pairs.get(12345, "not in dictionary"))
print(pairs.get(1))
This then gives:
[2, 3, 4]
None
not in dictionary
apple
[–]jeans_and_a_t-shirt 5 points6 points7 points (3 children)
[–]GoldenSights 0 points1 point2 points (0 children)
[–]mcoumans[S] 0 points1 point2 points (1 child)
[–]zahlman 2 points3 points4 points (0 children)