Getting min and max values

Lists and collections / Lists

numbers = [11, 2, 5, 7, 3]

min_value = min(numbers)
# min_value is 2

# default: the result for an empty list instead of ValueError
max_value = max(numbers, default=0)
# max_value is 11

# key: the element with the largest computed value
words = ["bb", "a", "cccc"]
longest = max(words, key=len)
# longest is 'cccc'

print(f"{min_value = }")
print(f"{max_value = }")
print(f"{longest = }")