Python Program to Find the Largest Number in a Given List

 Hey There,


In this video, I have shown how to find the largest number in a given list.


Consider the given list as : list = [2,4,6,8,1,9,3,0]


Now,sort the list to get the largest number at the last. The sorting can be done as : list.sort()


After sorting the list look like  : list = [0,1,2,3,4,6,8,9]


We got the largest number in the list at the end.


To print the last element in the list, we can write the code as : print(list[-1])


So,the code can be written as :

      list =  [2,4,6,8,1,9,3,0]
      list.sort()
      b = list[-1]
      print("Largest number in the given list is : ",b)

Output :

Python Program to Find the Largest Number in a Given List

Video Tutorial:




Comments

Popular posts from this blog

Python Program to Swap First and Last Element of a Given List

Python Program to Calculate the Average of Numbers in a Given List

Python Program to Put Even and Odd Elements of a List into Two Different Lists