I know d[key] will take the 'd' items and return them as keys, but if I only use d[key] I always get a keyerror. I've only seen it been used with .get(). For example I saw another question on here that I copied to study from:
myline = "Hello I'm Charles"
character = {}
for characters in myline:
character[characters] = character.get(characters, 0) + 1
print character
If you can use d[key] alone, could you give me some examples? Why wouldn't the above code work if I remove "character.get(characters, 0) + 1"?