Largest in List of Python
This program is to find the largest among the list elements using for loop. Logic here is to store first element in variable called large and iterate the rest of the elements using for loop from 1 to length of list. Now check if the element found is greater then the variable large then assign the current element value in large and continue the same.
Output of this will look like this. –
List elements are – [4, 5, 3, 2, 5, 7, 9, 1]
Largest element in list is – 9