Python set max method

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 Python max set function with practical examples.

The syntax behind this max function is:


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: Please refer to the Python article to understand everything about Sets.

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

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

This is another example of the function.

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