Student Handbook

Student Handbook

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

min

Returns the smallest of several values.

Synopsis

min(value1, value2, ...)
min(list)

Description

Give min two or more values, or one list.

Parameters

Name Meaning
values Two or more values, or one list. They must be comparable: all numbers, or all strings.

Return value

The smallest value.

Example

print(min(3, 7, 1))
print(min([4.5, 2.5, 9]))

It prints:

1
2.5

Common mistake

print(min("10", "9"))

It prints:

10

Strings are compared letter by letter, and "1" comes before "9", so "10" counts as smaller. Convert numbers you read with input before comparing them.

See also

max, sum, list.sort

min in the Python documentation

Last updated 2 weeks ago