Skip to content

Instantly share code, notes, and snippets.

@nonamenix
Last active July 30, 2020 10:13
Show Gist options
  • Save nonamenix/3934851d3abf8dc899ca9736da769c7c to your computer and use it in GitHub Desktop.
Save nonamenix/3934851d3abf8dc899ca9736da769c7c to your computer and use it in GitHub Desktop.
Choose winners
# Take unique participants and choose `n` random
# use python online https://www.programiz.com/python-programming/online-compiler/
PARTICIPANTS = """
ABC
DDD
EEE
FGH
"""
from random import choices
def prepare_participants(participants):
return list(set([participant.strip() for participant in participants.split("\n")]))
def choose_winners(participants, count=2):
return choices(participants, k=2)
if __name__ == "__main__":
participants = prepare_participants(PARTICIPANTS)
for winner in choose_winners(participants, count=2):
print(winner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment