Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

467 challenges 330 easy 120 medium 17 hard
Python Basics easy

Count word occurrences

Write a function that takes a sentence and returns a dictionary of word counts.

strings counting dictionaries
+10 pts 15m
Python Basics easy

Garbage Collection Hint

Write a function that predicts when an object is garbage collected based on reference counting.

garbage-collection reference-counting object-lifecycle
+10 pts 10m
Python Basics easy

Count Leading Zeros

Write a function that returns the number of leading zeros in a list of integers.

lists iteration counting
+8 pts 8m
Strings & Text easy

Count vowels

Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).

strings counting
+5 pts 5m
Strings & Text easy

Count words in a sentence

Implement a function to count words in a sentence, ignoring extra whitespace and handling empty strings.

strings split counting
+10 pts 10m
Strings & Text easy

Count consonants

Write a function that counts the number of consonant letters in a string.

strings counting loops
+10 pts 10m
Strings & Text easy

Count Syllables (Simple)

Count syllables in a word by counting groups of consecutive vowels (a, e, i, o, u).

strings vowels counting
+10 pts 15m
Strings & Text easy

Count Substrings

Implement a function that counts non-overlapping occurrences of a substring in a given string.

strings counting substrings
+10 pts 15m
Strings & Text easy

Most Common Character

Return the character that appears most frequently in a string, breaking ties by earliest occurrence.

strings counting dictionary
+10 pts 15m
Lists & Arrays easy

Majority Element Finder

Implement a function that returns the majority element in a list, which appears more than half the time.

majority frequency arrays
+10 pts 15m
Lists & Arrays easy

Difference of Two Lists

Write a function that returns items in list a that are not in list b, preserving order and duplicates.

lists difference counting
+8 pts 10m
Lists & Arrays easy

Counting Sort

Implement the counting sort algorithm to sort a list of non-negative integers in O(n + k) time.

sorting counting arrays
+10 pts 15m
Dicts & Sets easy

Merge dicts summing values

Write a function that merges two dictionaries by summing values for duplicated keys.

dicts merge sum
+10 pts 10m
Dicts & Sets easy

Are two lists the same multiset

Write a function that checks if two lists contain the same elements with the same multiplicities, ignoring order.

multiset dictionary counting
+10 pts 10m
Dicts & Sets easy

Mode of a list via counting

Implement a function that returns the mode of a list, resolving ties by the element that appears first.

counting dictionaries mode
+10 pts 15m
Dicts & Sets easy

Values that appear once

Return a list of numbers that appear exactly once in the input list, in original order.

counting filtering order
+10 pts 15m
Dicts & Sets easy

Pair with difference K

Count unordered index pairs with absolute difference exactly K, handling duplicates correctly.

dictionary set counting
+10 pts 15m
Dicts & Sets easy

Set intersection size

Count how many distinct values appear in both of two given lists.

sets intersection counting
+5 pts 8m
Dicts & Sets easy

Count Pairs with Sum

Implement a function that counts the number of distinct pairs in a list summing to a target.

dictionary pair-counting hash-map
+10 pts 15m
Dicts & Sets easy

Ransom Note Builder

Given two strings, determine if the ransom note can be formed from the words in the magazine.

dictionary counting strings
+10 pts 15m
Data Structures & Algorithms medium

Count inversions lite

Implement a function that counts inversions in a list of numbers efficiently.

inversions sorting merge sort
+25 pts 25m
Data Structures & Algorithms easy

Count pairs with given difference

Count how many unordered pairs in a list have a given absolute difference using an efficient approach.

hash map counting arrays
+12 pts 15m
Data Structures & Algorithms medium

Radix Sort

Implement LSD radix sort to sort a list of non-negative integers in ascending order.

radix-sort sorting counting-sort
+25 pts 25m
Data Structures & Algorithms medium

Decode Ways

Count the number of ways to decode a numeric string into letters using the mapping A=1 to Z=26.

dynamic programming strings counting
+20 pts 25m
Math & Number Theory easy

Power set size

Compute the size of the power set of a given sequence.

math subsets counting
+8 pts 10m
Math & Number Theory easy

Count divisors

Compute the number of positive divisors of a given integer using its prime factorization.

divisors prime factorization math
+10 pts 15m
Bit Manipulation easy

Count Set Bits

Implement a function that returns the number of set bits (1s) in the binary representation of a non-negative integer.

bit-manipulation binary counting
+10 pts 15m
Bit Manipulation easy

Brian Kernighan count

Implement a function that counts set bits using Brian Kernighan's efficient algorithm.

bit-manipulation integers counting
+10 pts 15m
Dynamic Programming easy

Climbing Stairs

Implement a function that returns the number of distinct ways to climb n stairs using steps of 1 or 2.

fibonacci dp counting
+10 pts 15m
Dynamic Programming easy

Unique Paths in a Grid

Count the number of unique paths from the top-left corner to the bottom-right corner of a grid, moving only right and down.

dynamic-programming grid counting
+15 pts 20m
Dynamic Programming medium

Target Sum Subsets

Write a function that counts the number of subsets of a list of positive integers that sum exactly to a target.

subset-sum dp counting
+25 pts 30m
Dynamic Programming medium

Coin Change Ways

Count the number of distinct combinations of coins that sum to a target amount.

dynamic programming coins counting
+30 pts 25m
Two Pointers & Sliding Window medium

Count Nice Subarrays

Given an array of integers, count the number of contiguous subarrays that contain exactly k odd numbers.

sliding-window two-pointers subarray
+25 pts 25m
Two Pointers & Sliding Window hard

Subarrays with K different ints

Count the number of contiguous subarrays that contain exactly K distinct integers.

sliding-window two-pointers hashmap
+40 pts 40m
Heaps & Priority Queues medium

Top K Frequent Elements

Given an integer array and a number k, return the k most frequent elements using a heap-based approach.

heap frequency counting
+25 pts 25m

Showing 35 challenges

Guide: free Python coding challenges

Practice Python by solving problems

PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.

How to use the arena

  1. Pick a category — basics, algorithms, strings, and more
  2. Open a challenge, read the statement, and edit the starter code
  3. Run tests, fix failures, then try a related quiz or tutorial lesson

Challenges vs tutorials and quizzes

Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.