Sorting a List
Putting a list in order can be a useful technique, and whilst there are various sorting algorithms you can program, python lists have a built in method for sorting.
- subjects = ["maths", "music","english", "french", "biology", "art"]
- subjects.sort()
This would put the list in alphabetical order, so ["art","biology","english","french","maths","music"]
You can also put a list in descending order:
- subjects.sort(reverse=True)