Compilador de Python Online (Editor / Interpretador)
Escreva, execute e compartilhe o seu código Python instantaneamente com o Compilador de Python Online da Asimov Academy.
dic = {'chave1': 'valor1', 'chave2': 'valor2'}
for chave in ['chave1', 'chave2', 'chave3']:
valor = dic.get(chave) # Pode retornar None se a chave não existir!
print(valor.upper())
# na última iteração...
# AttributeError: 'NoneType' object has no attribute 'upper'