Lazo Lab Sign up

Python Fundamentals / Collections

Lesson 22 of 38

List methods

append() adds to the end, insert() adds at a position, remove() deletes a value, pop() removes and returns an item, and sort() orders the list.

Key points

  • append(x) adds at the end
  • pop() removes the last item
  • sorted(list) returns a new list
nums = [3, 1, 2]
nums.append(5)
nums.sort()
print(nums)  # [1, 2, 3, 5]
Watch a video on thisOpens YouTube search results for “List methods” in a new tab

Quiz · +10 XP

Which method adds an item to the end of a list?

Log in to save progress and earn XP.