Editor

Python list exercises

Python list problems, from indexing and slicing to comprehensions and in-place changes, each checked by tests in your browser.

Beginner

  1. 9. Count ElementHow many times does it appear?40 XP4 min
  2. 11. Sum of ListAdd up a list the long way40 XP4 min
  3. 13. Find MaximumThe largest value, found by hand45 XP5 min
  4. 14. Reverse a ListBack to front45 XP5 min
  5. 26. Flatten One LevelBoxes inside a box: tip them all out onto the table25 XP4 min
  6. 39. The Missing NumberEvery number from zero upwards is here, except one35 XP5 min
  7. 205. Running TotalHow does the balance look after each payment?25 XP4 min
  8. 209. Above AverageWhich days beat the monthly average?30 XP5 min
  9. 212. Chunk a ListSix eggs to a box: how do the boxes fill up?30 XP5 min
  10. 243. Second Largest ValueWho takes the silver medal when ties share the gold?35 XP6 min
  11. 501. Already in Order?Check whether a list is already sorted before sorting it25 XP4 min
  12. 505. Day-to-Day ChangesDid the temperature go up or down since yesterday?25 XP4 min
  13. 508. Every Position of a ValueWhere in the line does this number turn up, every single time?25 XP3 min
  14. 511. Odds and EvensSort a pile of numbers into two teams and count each side25 XP3 min
  15. 512. Pass and Fail ListsThe marks are in: who passed and who needs another try?25 XP4 min
  16. 513. Remove Every CopyClear one unwanted item out of the list, every last one of it25 XP4 min
  17. 535. Closest to the TargetGuess the jelly beans in the jar: whose guess came closest?30 XP5 min
  18. 553. Take TurnsTwo lines of players merge into one, taking turns30 XP5 min
  19. 555. The Coldest DayA summer weather report that finds a day nobody recorded30 XP4 min
  20. 556. The Last N ItemsThe tail end of a list, any length you like30 XP4 min

Intermediate

  1. 18. Remove DuplicatesEvery item once, order kept60 XP7 min
  2. 55. Rotate a ListSpin the list around without losing anyone55 XP8 min
  3. 78. Common to Every ListWhat do all the shopping lists have in common?70 XP14 min
  4. 97. Rotate the GridTurn a square picture a quarter turn to the right75 XP12 min
  5. 107. Merge Overlapping IntervalsOverlapping bookings melt into one long block85 XP15 min
  6. 114. Product of All the OthersEvery number, multiplied by everyone except itself90 XP15 min
  7. 275. Row of Pascal's TriangleA famous triangle of numbers, one row at a time60 XP10 min
  8. 583. Judges' Average ScoreThrow out the highest and lowest marks, then average the rest60 XP7 min
  9. 591. Remove the Short WordsSome short words escape the filter, but only when they sit together65 XP8 min
  10. 624. Rainfall Between Two DaysOne long weather record and a flood of questions about it65 XP12 min

Advanced

  1. 121. Insert an IntervalA new booking lands in an already busy calendar115 XP20 min
  2. 122. Many Range UpdatesThousands of edits to a long list, and only the final result matters115 XP18 min
  3. 153. Balanced Zeros and OnesThe longest stretch where zeros and ones are perfectly even140 XP25 min
  4. 168. Make the Sum DivisibleCut out the shortest stretch so the total divides evenly165 XP30 min

Expert

  1. 196. Rectangles That Sum to TargetHow many blocks of the grid add up to exactly the target?260 XP50 min

Other topics

Or see every challenge, with study plans, today's challenge and duels.