Last in Line#
Say a list is stored in a variable named lst
, and assume that the list isn’t empty (it has at least one element in it).
## Which expression will return the **last** element in the list?
> (A) returns the first element. (B) will raise an error (index out of range). (C) will also raise an error (unsupported operand). (D) works, as would `lst[-1]`.
1. [ ] `lst[0]`
2. [ ] `list[len(lst)]`
3. [ ] `lst[len(lst - 1)]`
4. [x] `lst[len(lst) - 1]`
5. [ ] None of the above