Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
list_students = '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'
while True:
try:
ordered_list = None
by_lowest = int(input('0 - sorted for the lowest. \n1 - sorted for the highest\n'))
if not by_lowest:
ordered_list = sorted(list_students.split(','))
else:
ordered_list = reversed(sorted(list_students.split(',')))
break
except Exception:
print('Please select 0 or 1.')
for i in ordered_list:
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.