Find Largest Number in a List using Python



In this article, we will learn about the solution and approach to solve the given problem statement.

Problem statement

Given list input, we need to find the largest numbers in the given list .

Here we will discuss two approaches

  • Using sorting techniques
  • Using built-in max() function

Approach 1 − Using built-in sort() function

Example

 Live Demo

list1 = [18, 65, 78, 89, 90]
list1.sort()
# main
print("Largest element is:", list1[-1])

Output

Largest element is: 90

Approach 2 − Using built-in max() function

Example

 Live Demo

list1 = [18, 65, 78, 89, 90]
# main
print("Largest element is:",max(list1))

Output

Largest element is: 90

Conclusion

In this article, we learnt about the approach to find largest number in a list.

Updated on: 2020-07-04T12:37:12+05:30

276 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements