Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Sort lists in-place with sort() and compare with sorted()
scores = [88, 72, 95, 64, 81]
# 1. Non-destructive sort using built-in sorted()
ascending_copy = sorted(scores)
# 2. In-place descending sort using scores.sort(reverse=True)
scores.sort(reverse=True)
print("Non-destructive sorted copy:", ascending_copy)
print("In-place descending sorted original:", scores)