Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about how to find Maximum Value in a List in Python. so without wasting time lets learn about of this.
How to find Maximum Value in a List in Python
- find Maximum Value in a List in Python
To find Maximum Value in a List in Python Use max() you can find the maximum value in a list in python. This is the simplest way to find it out. So lets learn about of this. I hope yo guys like it most.
mylist = [3,15,1,9,8,56] print(max(mylist))
Output :56
- to find Maximum Value in a List in Python
To find Maximum Value in a List in Python For the list of strings you can find out maximum value by this method. You can better understand by given below example. so lets learn about of this:
strings = ["salt","chocolate","rice","dal","haldi"] max_value = max(strings) print('Maximum value:', max_value, "At index:", strings.index(max_value))
Output :Maximum value: salt At index: 0
Thus you can find out the maximum value of list which is made off strings.
Method 1: Using max()
By using max() you can find the maximum value in a list. This is the simplest way to find it out. So lets learn about of this. I hope yo guys like it most.
mylist = [3,15,1,9,8,56]
print(max(mylist))
Output :
56
This is the simplest one.
Method 2: using max() for list of strings
For the list of strings you can find out maximum value by this method. You can better understand by given below example. so lets learn about of this:
strings = ["salt","chocolate","rice","dal","haldi"]
max_value = max(strings)
print('Maximum value:', max_value, "At index:", strings.index(max_value))
Output :
Maximum value: salt At index: 0
Thus you can find out the maximum value of list which is made off strings.
Method 3: Using reduce()
By using reduce() you can find out the maximum value of list in python. So lets learn obout of this through example:
from functools import reduce
list1 = [19,11,1,9,97,34,35]
print(reduce(max, list1))
Output :
97
Thus you can find out the maximum value in list
Conclusion
It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?
Also, Read