Find Minimum of Items in a Tuple
To find minimum of items in a Tuple in Python, use min() builtin function. We can also provide a key function for min() to transform the items and then find the minimum of those values.
Minimum of Tuple of Integers
In the following program, we take a tuple
x with integer values, and find the minimum item in this tuple.
aTuple = (2, 5, 8, 1, 4, 3) result = min(aTuple) print('Minimum :', result)Try Online
Minimum : 1
Minimum of Tuple of Strings based on Length
Here key is length of the item. To find minimum of strings based on length, call min() function and send len() function as key parameter.
aTuple = ('Tea', 'Banana', 'Pomegranate') result = min(aTuple, key=len) print('Minimum :', result)Try Online
Minimum : Tea
In this Python Tutorial, we learned how to find the minimum of items in a Tuple in Python using min() function.