Python has a built-in function max() which makes it super easy
list = [3,8,2,9] max_number = max(list) print (max_number) # it will print 9 as big number
There will be occasions when you want to do it manually, and it’s also good to know how it works under the hood.
list = [3,8,2,15,9,12] current_max_number = list for number in list: if number>current_max_number: current_max_number = number print (current_max_number) #it will display 15 as big number
Have any questions or comments? Write them below!
Leave a Reply