How to check if a key exists in Python dictionary