Last active
July 30, 2020 10:13
-
-
Save nonamenix/3934851d3abf8dc899ca9736da769c7c to your computer and use it in GitHub Desktop.
Choose winners
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
# 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