Python List Maximum
max()Practice

Find the highest score in a list

Read a list of integers, then print the maximum. Like finding the winner in a class quiz — the highest bar wins.

Picture this: walk and keep the winner

Start with the first item. If you see a bigger one, it becomes the winner.

best = firstso far
→
next itemcompare
→
bigger?update best
→
end of listbest is max

Diagram — track the max so far

best = first scan each item update if bigger

In easy words: What is this problem?

You have a list of numbers, and you need the biggest one. This is like scanning a class score sheet and picking the top score.

Where this is used

Used in leaderboards, highest temperature in a week, most expensive product in a cart, or best performance metric in analytics dashboards.

Theory: max() and indexing

  • max(nums) scans every item and returns the largest value.
  • Works on any list of comparable items — numbers, strings, dates.
  • To find where the max is, use nums.index(max(nums)).

Real world: exam leaderboard

A teacher's portal stores scores as a list. max(scores) instantly finds the top mark for the trophy row — no manual scanning needed.

Bar chart — tallest bar = maximum

max = ?
1nums = list(map(int, input().split()))
2print(max(nums))

Example Program

1nums = [3, 9, 1, 7]
2print(max(nums))