Example
List Methods - append, insert, pop
Adding and removing elements from list. Methods append, insert, pop and remove.
Showing 1–10 of 92
Example
Adding and removing elements from list. Methods append, insert, pop and remove.
Example
Accessing list elements by index. Changing and removing elements.
Challenge
…remembers samples from earlier calls, because the default list is created once and shared. Predict it, prove the calls share one list, fix it with None as the default, then write a function that hands…
Challenge
add_reading() appends to the list it receives, so the caller's stored readings change too. Predict the first line, prove both names share one list, fix it by returning a new list, then write a filter…
Example
Methods sort() and reverse() for ordering list elements.
Example
When to use tuples instead of lists? Comparison of properties and applications.
Example
Lists store multiple elements in a specific order. Basics of working with lists.
Quiz
Free beginner quiz on Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Example
…can return complex data structures like dictionaries or lists.
Challenge
…add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that can't pass either.