Dictionary comprehension is a more recent addition to the Python language. The code below makes a dictionary D with words (strings) as the key, and whether or not that word ends with "s" as the boolean value.
Li = ["old","sons","as","here"] |
D = { w:(w[-1]=='s') for w in Li } |
New = {"A":ord("A"), "B":ord("B") } |
print New["B"] == ord("B") |