append_and_insert.md

June 22, 2022 ยท View on GitHub

Append & Insert

  1. Given the list li = [2, 0, 2, 2]

    1. Append to the end of the list the number 7
    2. Insert to the beginning of the list the number 1
    3. Insert in the second place the number 20
  2. What will be the result of running the following line? li.insert(20, 0)

Solution

    1. li.append(7)
    2. li.insert(0, 1)
    3. li.insert(1, 20)
  1. It will append 0 to the end of the list