We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Find Min

In this problem you'll need a way to represent the largest possible number: infinity. In Python, you can use this constant to represent positive infinity:

my_infinity: float = float("inf")

Assignment

Write a function called find_min() that finds the smallest number in a list. If the list is empty, return float("inf"). For example:

  • find_min([1, 3, -1, 2]) -> -1
  • find_min([18, 3, 7, 2]) -> 2

Do not use the built-in min() function.

Tips

    • If the current number is less than the "smallest number so far," update the "smallest number so far" to the current number.