-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpratica106.py
More file actions
36 lines (30 loc) · 805 Bytes
/
pratica106.py
File metadata and controls
36 lines (30 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Exercicio unir listas
# Crie uma funcao
# O trabalho dessa função será unir duas listas na ordem
# Use todos valores da menor lista.
# Ex.:
# ['Salvador', 'Ubatuba', 'Belo Horizonte']
# ['BA', 'SP', 'MG', 'RJ']
from itertools import zip_longest
cidades = [
'Salvador',
'Ubatuba',
'Belo Horizonte',
]
estados = [
'BA',
'SP',
'MG',
'RJ',
]
# Crie uma função zipper
#def zipper(cidades, estados):
# intervalo = min(len(cidades), len(estados))
# for indice in range(intervalo):
# return [
# (cidades[indice], estados[indice]) for indice in range(intervalo)
# ]
#print(zipper(cidades, estados))
# Modo Pythonico.
print(list(zip(cidades, estados)))# Importando itertools
print(list(zip_longest(cidades, estados, fillvalue='SEM CIDADE')))