Skip to content

Instantly share code, notes, and snippets.

@gaspart
Created November 20, 2019 13:37
Show Gist options
  • Save gaspart/5d68f757bb7b96e0ad87b8281e5f0545 to your computer and use it in GitHub Desktop.
Save gaspart/5d68f757bb7b96e0ad87b8281e5f0545 to your computer and use it in GitHub Desktop.
transform a string into a list, then sort descending and choose random
from random import choice
a_list = '54 - Alice,35 - Bob,27 - Carol,27 - Chuck,05 - Craig,30 - Dan,27 - Erin,77 - Eve,14 - Fay,20 - Frank,48 - Grace,61 - Heidi,03 - Judy,28 - Mallory,05 - Olivia,44 - Oscar,34 - Peggy,30 - Sybil,82 - Trent,75 - Trudy,92 - Victor,37 - Walter'
myList = a_list.split(',')
myList.sort(reverse=True)
print(myList)
print()
print(choice(myList))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment