Example
List Methods - append, insert, pop
Adding and removing elements from list. Methods append, insert, pop and remove.
Showing 1–10 of 16
Example
Adding and removing elements from list. Methods append, insert, pop and remove.
Challenge
…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.
Quiz
…Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Article Mini projects
…cursor = conn.cursor() cursor.execute("INSERT INTO astronauts (name, age, nationality) VALUES (?, ?, ?)", (name, age, nationality)) conn.commit() conn.close() # Clear the entry fields…
Example
F-strings are a modern way to format text in Python. Insert variables directly into text.
Challenge
…each line without its line break: [T+00:10:00] INFO Orbit insertion complete [T+00:12:05] WARN Battery 3 temperature high [T+00:14:47] ERROR Fuel valve 2 not responding The hidden tests also open…
Challenge
…since launch, after the three lines from before: Orbit insertion: T+0:11:12 Solar array deployed: T+0:32:00 First image: T+3 days, 4:15:30 Parse each timestamp as it is, offset included, and subtract…
Quiz
Free Python quiz for beginners: 20 multiple-choice questions on print(), strings, lists, dictionaries, loops and functions, with instant answers.
Challenge
Turn the launch-day mission log into answers: parse each line into a dict, count the entries per level and per hour, find the first ERROR, then rank the subsystems by how many warnings they raised.
Challenge
Count the entries and the WARN lines in a multi-line mission log with count(), fix the count when a message mentions WARN itself, then summarise the log by level.