Python set max

Python max function is one of the methods used to find the maximum value within the given set. In this section, we discuss how to use this max set function with practical examples.

The syntax behind this max function is:

max(set_Name)

Python set max Example

The set max function helps you to find the maximum items from the total number of items in a given set. The below code returns the item with the highest Numeric Value from a maximumSet.

TIP: Check out the Python set article available on our Python tutorial page to understand the creation of sets.

maximumSet = {15, 25, 35, 45, 55}
print("\nSet Items = ", maximumSet)

print("Maximum Value in a Set = ", max(maximumSet))
set max method Example

This is another example of the set max function. Please refer to the Python max and Python set min functions from the list of available Python set functions.

maximumFruitSet = {'mango', 'kiwi', 'apple', 'orange', 'banana'}
print("\nSet Items = ", maximumFruitSet)

# Python Set Maximum
print("Maximum Value in a Set = ", max(maximumFruitSet))

Set Items =  {'banana', 'mango', 'kiwi', 'orange', 'apple'}
Maximum Value in a Set =  orange