From 8436a008ab27b3d7ca7668914c4220e7141fcbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Mon, 7 Nov 2022 13:55:45 -0300 Subject: [PATCH] =?UTF-8?q?(Parte=202)=20M=C3=A9todos=20=C3=BAteis=20nos?= =?UTF-8?q?=20dicion=C3=A1rios=20Python=20(dict)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula76.py | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/aula76.py b/aula76.py index 3c4ebe4..13edb2e 100644 --- a/aula76.py +++ b/aula76.py @@ -13,31 +13,21 @@ p1 = { 'nome': 'Luiz', 'sobrenome': 'Miranda', } - -# p1.update({ -# 'nome1': 'AAAA', -# 'sobrenome1': 'BBBB', -# 'idade': 123, -# }) -# p1.update(idade=123, nome='Qualquer outro') -variavel = (1,) -print(variavel) -p1.update( - ( - ('Chave', 'Valor'), - ('Chave1', 'Valor1'), - ('Chave2', 'Valor1'), - ) -) -print(p1) -# print(p1.get('nome', 'Valor padrão')) +# print(p1['nome']) +# print(p1.get('nome', 'Não existe')) # nome = p1.pop('nome') # print(nome) # print(p1) - -# ultima_chave = p1.popitem() -# print(ultima_chave) # ultima_chave = p1.popitem() # print(ultima_chave) # print(p1) +# p1.update({ +# 'nome': 'novo valor', +# 'idade': 30, +# }) +# p1.update(nome='novo valor', idade=30) +# tupla = (('nome', 'novo valor'), ('idade', 30)) +lista = [['nome', 'novo valor'], ['idade', 30]] +p1.update(lista) +print(p1)