Problem 169700 · easy · Phase 01 Prerequisites & Setup

In-Stock Products

lists · zip · filtering

A shop keeps two lists of the same length: names of products and quantities on hand. Write in_stock(names, quantities) that returns a new list of the names whose quantity is greater than 0, in the original order.

Examples

Input:  names = ["pen", "ink", "pad"], quantities = [3, 0, 12]
Output: ["pen", "pad"]

Input:  names = ["cup"], quantities = [0]
Output: []

Constraints

  • len(names) == len(quantities)
  • 0 <= len(names) <= 5000

Goals

  • Walk two parallel lists together
  • Filter one list based on values in the other
Starting Python…