Learn › Class 11 › Computer Science / Informatics Practices › Lists, tuples, dictionaries
Lists, tuples and dictionaries
Remember
- List: ordered, mutable, [ ]. Tuple: ordered, immutable, ( ). Dict: key–value pairs, { }.
- Index from 0; negative indexes count from the end; slices exclude the stop index.
- Use d.get(key, default) to avoid KeyError; d.items() gives key–value pairs.
Quick self-check
How do you add 7 to the end of list L?
Check
L.append(7).
Can a list be a dictionary key?
Check
No, because lists are mutable.