How to find the maximum and minimum values in a list in Python?

To find the maximum and minimum values in a list in Python, you can use the built-in functions max() and min().

Here's an example:

# Example list my_list = [5, 8, 2, 10, 3] # Finding the maximum value maximum = max(my_list) print("Maximum value:", maximum) # Finding the minimum value minimum = min(my_list) print("Minimum value:", minimum)

Output:

Maximum value: 10 Minimum value: 2

You can use these functions on any list containing numeric or comparable values.