Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Sort a list of student scores
- scores = '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'
- scores = scores.split(',')
- for x in sorted(scores):
- print(x)
- #now print in reverse order
- for x in reversed(sorted(scores)):
- print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement