← Back to challenges

List Index

PythonHardarraysloopsfunctional_programminglanguage_fundamentals

Instructions

Given a 2D-list of letters lst and a list of indexes idx, find the letters on given indexes and return as a string.

lst = [
  ["m", "u", "b"],
  ["a", "s", "h"],
  ["i", "r", "1"]
]

idx = [1, 3, 5, 8]

You have to find the characters in these indexes of the given list if you think of the indexes as:

[
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]
list_index(lst, idx) ➞ "mbsr"

Notes

Remember that the indexes start from one and not zero.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Simple Counting