- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to find the largest number in a list
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a list, we need to calculate the largest element of the list.
Here we will take the help of built-in functions to reach the solution of the problem statement
Using sort() function
Example
# list list1 = [23,1,32,67,2,34,12] # sorting list1.sort() # printing the last element print("Largest element is:", list1[-1])
Output
Largest in given array is 67
Using max() function
Example
# list list1 = [23,1,32,67,2,34,12] # printing the maximum element print("Largest element is:", max(list1))
Output
Largest in given array is 67
We can also take input from the user by the code given below
Example
# empty list list1 = [] # asking number of elements to put in list num = int(input("Enter number of elements in list: ")) # appending elements in the list for i in range(1, num + 1): ele = int(input("Enter elements: ")) list1.append(ele) # print maximum element print("Largest element is:", max(list1))
Conclusion
In this article, we have learned how to get the largest element from the list.
- Related Articles
- Python program to find largest number in a list
- Python program to find the second largest number in a list
- Python Program to Find the Second Largest Number in a List Using Bubble Sort
- Python Program to Find the Largest Element in a Doubly Linked List
- Program to find lexicographically largest mountain list in Python
- Python program to find Largest, Smallest, Second Largest, and Second Smallest in a List?
- Python program to find N largest elements from a list
- Golang Program to Print the Largest Even and Largest Odd Number in a List
- Program to find the largest grouping of anagrams from a word list in Python
- Python program to find the smallest number in a list
- C# program to find Largest, Smallest, Second Largest, Second Smallest in a List
- Program to find largest kth index value of one list in Python
- Program to find largest sum of non-adjacent elements of a list in Python
- Python Program for Find largest prime factor of a number
- Program to find largest distance pair from two list of numbers in Python

Advertisements