Write a program to find the Largest Number in a List in Python
In this tutorial we are going to learn about finding the Largest Number in a List in Python.
Python Program to Find the Largest Number in a List
a= n=int(input("Enter number of elements:")) for i in range(1,n+1): b=int(input("Enter element:")) a.append(b) a.sort() print("Largest element is:",a[n-1])
- User must enter the number of elements and store it in a variable.
- User must then enter the elements of the list one by one using a for loop and store it in a list.
- The list should then be sorted.
- Then the last element of the list is printed, which is also the largest element of the list.