List methods in Python
The mutating operations every Python list supports.
stack = [3, 1, 4]
stack.append(1)
stack.insert(0, 5)
top = stack.pop()
stack.remove(1)
stack.sort()
stack.reverse()
where = stack.index(4)
count = stack.count(3)
stack.extend([9, 2])
How it works
append,insert, andpopchange the ends.removedeletes by value;indexfinds one.sortandreversereorder in place.
The run, in numbers
- Lines
- 12
- Characters to type
- 184
- Tokens
- 72
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 48 seconds.
Step 3 of 10 in Collections, step 25 of 72 in Language basics.