From 56d58c1be3a406e9497ba151b169829fb9e55afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sun, 6 Nov 2022 09:54:59 -0300 Subject: [PATCH] =?UTF-8?q?Solu=C3=A7=C3=A3o=20do=20Exerc=C3=ADcio=20+=20z?= =?UTF-8?q?ip=20e=20zip=5Flongest=20do=20itertools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula107.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aula107.py b/aula107.py index 33680b5..ff60905 100644 --- a/aula107.py +++ b/aula107.py @@ -8,3 +8,13 @@ # ['BA', 'SP', 'MG', 'RJ'] # Resultado # [('Salvador', 'BA'), ('Ubatuba', 'SP'), ('Belo Horizonte', 'MG')] + +# def zipper(l1, l2): +# intervalo = min(len(l1), len(l2)) +# return [(l1[i], l2[i]) for i in range(intervalo)] +from itertools import zip_longest + +l1 = ['Salvador', 'Ubatuba', 'Belo Horizonte'] +l2 = ['BA', 'SP', 'MG', 'RJ'] +print(list(zip(l1, l2))) +print(list(zip_longest(l1, l2, fillvalue='SEM CIDADE')))