Practice by topic / Python & code / Python

Python Lists Exercises

Python is the most popular language for automating work: cleaning data, renaming files, crunching numbers. Each exercise runs your real code in the browser and checks it. These 5 exercises build up step by step, starting with total the sales, best and worst month, add a new client.

3 of 5 free · no sign-up needed · instant feedback

1

Total the Sales

Free

Create <code>total</code>: the sum of all numbers in <code>sales</code>.

Show the solution

total = sum(sales)

Right — sum() adds up a whole list in one go.

Try it in the live editor →
2

Best and Worst Month

Free

Create <code>best</code> (the highest value) and <code>worst</code> (the lowest value) in <code>sales</code>.

Show the solution

best = max(sales) and worst = min(sales)

Good — max() and min() work on any list of numbers.

Try it in the live editor →
3

Add a New Client

Free

Add <code>"Delta"</code> to the end of the <code>clients</code> list.

Show the solution

clients.append("Delta")

Right — .append() adds one item to the end of a list.

Try it in the live editor →