Lesson 17 of 34
List Methods: Add, Remove, Sort
9 min 25 XP
append() adds to the end, insert() adds at a position, remove() deletes a value, and pop() takes out the last item.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.For number lists, sum(), max() and min() are very handy. sort() orders from small to large; sort(reverse=True) does the opposite.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.To read many numbers from one line: input().split() gives a list of strings; convert each one to int.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.