Skip to content

Instantly share code, notes, and snippets.

@leydson-vieira
Last active December 12, 2018 13:27
Show Gist options
  • Save leydson-vieira/41ca43db001ac67e90ccc10e3f000ee8 to your computer and use it in GitHub Desktop.
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
#! /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