← Back to challenges

Return Last Item

PythonMediumarraysdata_structuresloops

Instructions

Create a function that returns the last value of the last item in a list or string.

Examples

last_ind([0, 4, 19, 34, 50, -9, 2]) ➞ 2

last_ind("The quick brown fox jumped over the lazy dog") ➞ "g"

last_ind([]) ➞ None

Notes

  • Lists/strings will be of varying size.
  • Return None if list/string is empty.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: A Day at the Market