Skip to content
← Back to the archive

1 September 2026

Safe Temperatures

Easy Lists Numbers

Keep the readings that are inside a chosen safe range.

You are given greenhouse temperature readings, plus a lowest safe temperature and a highest safe temperature. Look at each reading in order. Keep it when it is at least the lowest safe temperature and at most the highest safe temperature. Return the kept readings in the same order. The two safe limits are included. Return an empty list when no reading is safe.

Constraints

  • readings contains at most 100 whole numbers
  • lowest_safe is less than or equal to highest_safe
  • Every reading is a whole number

Function signature

def safe_temperatures(readings, lowest_safe, highest_safe):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.