Home / Python / Collections

Lists

A list holds ordered items in square brackets. You can add, remove and change items. A loop is the usual way to walk through one. For named items, see dicts.

nums = [3, 1, 2]
nums.append(9)
nums.sort()
print(nums)

Test yourself on this