Back to Freecodecamp

Step 4

curriculum/challenges/english/blocks/learn-lambda-functions-by-building-an-expense-tracker/666951d2e4b27e3a3c72ca5f.md

latest836 B
Original Source

--description--

You can also access a single element to get its value.

Lists are zero-indexed like strings are. That means that the first element is at index 0, the second element is at index 1 and so on.

To access an element you use bracket notation. For example, example_list[1] is accessing the element at index 1, the second element, of example_list.

Print the first element of my_list.

--hints--

You should print the first element of the list with print(my_list[0]).

js
({
    test: () => runPython(`
calls =  _Node(_code).find_calls("print")
assert any(call.is_equivalent('print(my_list[0])') for call in calls), "print of my_list[0] not found"
    `)
})

--seed--

--seed-contents--

py
--fcc-editable-region--
my_list = [1, 2]

my_list.append(3)
print(my_list)
--fcc-editable-region--