Editor

Python Exercises

200 exercises with a Check button that tests your code. Each one links to the lesson that teaches it.

Start with the 50 practice problems

Classic problems from FizzBuzz to an LRU cache, in order of difficulty. Also on one page.

  1. FizzBuzz
  2. Reverse the Words
  3. Count the Vowels
  4. Palindrome Check
  5. Sum of Digits
  6. Largest Number Without max()
  7. Remove Duplicates, Keep the Order
  8. Second Largest Value
  9. Most Common Character
  10. Are They Anagrams?
  11. Factorial, With a Proper Error
  12. Is It Prime?
  13. Letter Grade
  14. Title Case Without .title()
  15. Common Elements
  16. Flatten a List of Lists
  17. Merge Two Inventories
  18. Invert a Dictionary
  19. Password Strength Check
  20. Average of Messy Input
  21. Fibonacci Generator
  22. Sieve of Eratosthenes
  23. Caesar Cipher
  24. Top Words in a Text
  25. Group the Anagrams
  26. Balanced Brackets
  27. Run-Length Encoding
  28. Binary Search
  29. Merge Two Sorted Lists
  30. Rotate a List
  31. Deep Flatten
  32. Roman Numerals
  33. Longest Common Prefix
  34. Parse a Log Line With Regex
  35. A Bank Account Class
  36. Two Sum
  37. Longest Substring Without Repeats
  38. Merge Overlapping Intervals
  39. Top K Frequent Elements
  40. Maximum Subarray (Kadane)
  41. Coin Change (Dynamic Programming)
  42. Longest Increasing Subsequence
  43. Shortest Path in a Graph (BFS)
  44. LRU Cache
  45. Trie for Autocomplete
  46. Write a Memoize Decorator
  47. A Retry Decorator With Arguments
  48. A Context Manager That Cleans Up
  49. Revenue by Region With pandas
  50. Leaderboard With a Dataclass

Python Fundamentals

Control Flow

Data Structures