Last active
December 12, 2018 13:27
-
-
Save leydson-vieira/41ca43db001ac67e90ccc10e3f000ee8 to your computer and use it in GitHub Desktop.
script para sortear pares de amigos secretos através de uma lista separada por vírgulas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
import random | |
def choose_name(names): | |
name = random.choice(names) | |
names.remove(name) | |
return name | |
names = input('Digite os nomes separados por vírgula. (Ex: Rodrigo, Raphael, Ralph...): \n') | |
names_list = [n.strip() for n in names.split(',')] | |
if len(names_list) % 2 == 0: | |
count = 1 | |
while names_list: | |
name = choose_name(names_list) | |
print('{} - {}'.format(count, name)) | |
if count % 2 == 0: | |
print('\n') | |
count += 1 | |
else: | |
print('Você digitou um número ÍMPAR de nomes. As duplas não encaixam.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment