Example
List Methods - append, insert, pop
Adding and removing elements from list. Methods append, insert, pop and remove.
Showing 11–20 of 92
Example
Adding and removing elements from list. Methods append, insert, pop and remove.
Challenge
…the commander, the newest member and the crew size from a list with [0], [-1] and len(), then add the second in command and the whole roster joined into one line.
Challenge
Check whether a payload ID is on the approved list with in, which matches whole items rather than parts of text, then normalise IDs typed by hand and print a clear cleared or not-cleared message.
Challenge
backup = crew gives one list two names, so removing someone from the backup removes them from the live roster too. Predict it, prove it with is, fix it with copy(), then plan a crew swap on a real…
Challenge
…level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.
Challenge
The mission report lists the crew alphabetically, but the sign-up order matters too: it decides who gets the first training slots. The same list has to be shown both ways. Make a sorted copy for the…
Challenge
Go through the mission log and build 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
The duty roster should list the crew alphabetically. One line of code was supposed to sort it, and since that line went in, the roster says None . Predict what it prints, find out where the crew went…
Challenge
…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
Write validate_cargo(item), which returns a list of everything wrong with a cargo record: missing fields and a negative mass, then a cargo ID that doesn't match the CG- and four digits format. An…