Python lists and maps
Work with ordered lists and key-value lookups. Follow a pickup roster, change a booking, or combine stock counts from two deliveries.
Lists · build and edit
- Filtered list comprehensionClear empty stock bins from the pick list
- List comprehension with str.stripClean the names on two visitor badges
- List item assignmentCorrect the second stop on a shuttle route
- list slice insertionInsert two pickup stops before the depot
- list.popTake a cancelled item off a packing list
- tuple snapshotFreeze the guest list used to print badges
Lists · positions and ranges
- List indexing and lenRead the second name on the pickup roster
- List slicingSelect two orders for the packing bench
- list.index and reverse searchFind both visits to the market
- reversedRead a receipt history newest first
Maps · look up and assign
- Conditional delRelease a locker only for its recorded owner
- Conditional dictionary assignmentChange a room assignment only if it is still current
- Dictionary assignment and lookupUpdate the count for a shelf label
- Dictionary key membershipFind a parcel whose driver is still unassigned
- dict.setdefaultKeep the first reservation for a seat
Maps · combine and transform
- Dictionary comprehensionAdd a packing charge to each listed price
- Dictionary update for existing keysReduce only the stock that is on the ledger
- defaultdict(list)Group two parcels on one delivery route
- dict.copyKeep the price shown on yesterday's menu
- dict.itemsPrint shelf totals in aisle order
- dict.updateApply weekend opening hours
Other collection guides
- collections.CounterCount events and include missing categories
- bisect_left and bisect_rightCount equal prices in a sorted catalog
- itertools.groupbyCount consecutive runs of the same status
- Membership with inCheck for a price in a sale list
- dict.getShow a default when a product has no stock entry
- list.appendAdd a late item to a shopping list
- list.countCount items at the offer price
- list.indexLook up a rate by its position
- minFind the cheapest item in a basket
- sumAdd the prices on a shopping list