Dictionary
Aguiart
python
11 days ago
537 B
3
Indexable
#desafio 1 sorteios = ['sorteio1','sorteio2','sorteio3'] participantes = ['joel','jessica', 'maria','cris','Larissa', 'rafael', 'marcus', 'john'] import random from pprint import pprint ganhadores = random.sample(participantes, len(sorteios)) resultado = { sorteio: ganhador for sorteio, ganhador in zip(sorteios, ganhadores) } pprint(resultado) #desafio 2 grupos = ['grupo 1', 'grupo 2', 'grupo 3'] pprint({grupo: [random.randint(1, 101) for i in range(5)] for grupo in grupos})
Editor is loading...
Leave a Comment