Skip to content

Instantly share code, notes, and snippets.

@Alkz6
Created June 5, 2018 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alkz6/76750cb545790f50e17372dacc6ca839 to your computer and use it in GitHub Desktop.
Save Alkz6/76750cb545790f50e17372dacc6ca839 to your computer and use it in GitHub Desktop.
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