Example
List Methods - append, insert, pop
Adding and removing elements from list. Methods append, insert, pop and remove.
Showing 1–10 of 33
Example
Adding and removing elements from list. Methods append, insert, pop and remove.
Quiz
…quiz on Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
…a new list holding only the WARN and ERROR entries with append(), then let a minimum level decide what counts, the way logging tools filter by severity.
Challenge
Apply a day's crew changes to a list: append() a new member, insert() a backup at position 1, remove() someone who left, then pop() the newest member and print who was reassigned.
Challenge
…one per line, read the file back and print it, then add an append_entry() function that adds lines at the end without wiping what is there.
Challenge
Extend the working cargo console: record every change to the hold in a history list and show it with a history command, then add undo, which takes the last change off the history and reverses it.
Challenge
…reading has arrived. Add new_reading = 772 under the list, append it to the readings, then show the new window and how much the level changed between its first and last reading, with a sign…
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…
Article Mini projects
…limit reached" # Dispense the medication self.dose_history.append(current_time) return "DISPENSED: One dose of space aspirin delivered" # Grace's hack in action: dispenser = NaiveMedicationDispenser()…
Challenge
…dict. The loop still skips blank and comment lines, then appends parse_line(line) . None for lines that aren't readings Move the skipping into the function as well. parse_line() strips the line, so…