From e54d17eafe1c7f90b8d79f301af910f63a43cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sat, 29 Oct 2022 15:27:15 -0300 Subject: [PATCH] =?UTF-8?q?enumerate=20para=20enumerar=20valores=20de=20it?= =?UTF-8?q?er=C3=A1veis=20(pegar=20=C3=ADndices)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula53.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 aula53.py diff --git a/aula53.py b/aula53.py new file mode 100644 index 0000000..a0bd946 --- /dev/null +++ b/aula53.py @@ -0,0 +1,19 @@ +""" +enumerate - enumera iteráveis (índices) +""" +# [(0, 'Maria'), (1, 'Helena'), (2, 'Luiz'), (3, 'João')] +lista = ['Maria', 'Helena', 'Luiz'] +lista.append('João') + +for indice, nome in enumerate(lista): + print(indice, nome, lista[indice]) + +# for item in enumerate(lista): +# indice, nome = item +# print(indice, nome) + + +# for tupla_enumerada in enumerate(lista): +# print('FOR da tupla:') +# for valor in tupla_enumerada: +# print(f'\t{valor}')