Python list exercises
Python list problems, from indexing and slicing to comprehensions and in-place changes, each checked by tests in your browser.
Beginner
- 9. Count ElementHow many times does it appear?40 XP4 min
- 11. Sum of ListAdd up a list the long way40 XP4 min
- 13. Find MaximumThe largest value, found by hand45 XP5 min
- 14. Reverse a ListBack to front45 XP5 min
- 26. Flatten One LevelBoxes inside a box: tip them all out onto the table25 XP4 min
- 39. The Missing NumberEvery number from zero upwards is here, except one35 XP5 min
- 205. Running TotalHow does the balance look after each payment?25 XP4 min
- 209. Above AverageWhich days beat the monthly average?30 XP5 min
- 212. Chunk a ListSix eggs to a box: how do the boxes fill up?30 XP5 min
- 243. Second Largest ValueWho takes the silver medal when ties share the gold?35 XP6 min
- 501. Already in Order?Check whether a list is already sorted before sorting it25 XP4 min
- 505. Day-to-Day ChangesDid the temperature go up or down since yesterday?25 XP4 min
- 508. Every Position of a ValueWhere in the line does this number turn up, every single time?25 XP3 min
- 511. Odds and EvensSort a pile of numbers into two teams and count each side25 XP3 min
- 512. Pass and Fail ListsThe marks are in: who passed and who needs another try?25 XP4 min
- 513. Remove Every CopyClear one unwanted item out of the list, every last one of it25 XP4 min
- 535. Closest to the TargetGuess the jelly beans in the jar: whose guess came closest?30 XP5 min
- 553. Take TurnsTwo lines of players merge into one, taking turns30 XP5 min
- 555. The Coldest DayA summer weather report that finds a day nobody recorded30 XP4 min
- 556. The Last N ItemsThe tail end of a list, any length you like30 XP4 min
Intermediate
- 18. Remove DuplicatesEvery item once, order kept60 XP7 min
- 55. Rotate a ListSpin the list around without losing anyone55 XP8 min
- 78. Common to Every ListWhat do all the shopping lists have in common?70 XP14 min
- 97. Rotate the GridTurn a square picture a quarter turn to the right75 XP12 min
- 107. Merge Overlapping IntervalsOverlapping bookings melt into one long block85 XP15 min
- 114. Product of All the OthersEvery number, multiplied by everyone except itself90 XP15 min
- 275. Row of Pascal's TriangleA famous triangle of numbers, one row at a time60 XP10 min
- 583. Judges' Average ScoreThrow out the highest and lowest marks, then average the rest60 XP7 min
- 591. Remove the Short WordsSome short words escape the filter, but only when they sit together65 XP8 min
- 624. Rainfall Between Two DaysOne long weather record and a flood of questions about it65 XP12 min
Advanced
- 121. Insert an IntervalA new booking lands in an already busy calendar115 XP20 min
- 122. Many Range UpdatesThousands of edits to a long list, and only the final result matters115 XP18 min
- 153. Balanced Zeros and OnesThe longest stretch where zeros and ones are perfectly even140 XP25 min
- 168. Make the Sum DivisibleCut out the shortest stretch so the total divides evenly165 XP30 min
Expert
Other topics
- Python Basics
- Strings
- Dictionaries and sets
- Loops
- Functions
- Math
- Errors and exceptions
- File handling
- Modules and random
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Dynamic programming
- Greedy
- Graphs
- Trees
- Bit manipulation
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.