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
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
Strings & Text easy

Parse Log Line

Write a function that parses a log line and returns a dictionary with timestamp, level, and message.

string-parsing split strip
+10 pts 15m
Strings & Text easy

Parse key=value pairs

Implement a parser that converts a space-separated 'key=value' string into a Python dictionary, supporting quoted values.

parsing strings dictionaries
+8 pts 10m
Strings & Text easy

Replace template variables

Implement a function that replaces {{variable}} placeholders in a string using a dictionary, leaving unknown placeholders intact.

string-manipulation parsing template
+10 pts 15m
Lists & Arrays easy

Two Sum

Return indices (i, j) with i < j such that nums[i] + nums[j] == target.

dict complement
+18 pts 16m
Dicts & Sets easy

Word frequency

Return a dict mapping each word to its count in the sentence.

dict counter
+10 pts 10m
Dicts & Sets medium

Group anagrams

Group words that are anagrams of each other.

dict sorting strings
+22 pts 20m
Dicts & Sets easy

First non-repeating character

Find the index of the first character that appears only once.

dict strings counter
1
+12 pts 12m
Dicts & Sets easy

Most frequent element

Return the element that appears most often in a list.

counter dict
+8 pts 8m
Dicts & Sets medium

Subarray sum equals K

Count the number of contiguous subarrays whose sum equals k.

prefix-sum dict arrays
+28 pts 25m
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

Word to Index Map

Create a function that returns a dictionary mapping each unique word to the index of its first occurrence.

dictionary mapping indexing
+10 pts 10m
Dicts & Sets easy

Group names by first letter

Given a list of names, return a dictionary mapping each first letter to all names starting with that letter in original order.

dictionaries strings grouping
+10 pts 10m
Dicts & Sets easy

Missing keys default zero

Write a function to sum numeric values from dictionaries, treating missing keys as zero.

dictionaries sum defaults
+10 pts 12m
Dicts & Sets easy

Keys Sorted by Value Descending

Given a dictionary mapping strings to integers, return a list of keys sorted by value descending, and when values tie, alphabetically ascending.

sorting dictionaries ordering
+8 pts 10m
Dicts & Sets easy

Nested get with dotted path

Implement a function that safely retrieves a value from a deeply nested dictionary using a dot-separated path, returning a default if any key is missing.

dicts nested parsing
+8 pts 10m
Dicts & Sets easy

Anagram Dictionary Groups Lite

Group a list of words into anagrams using a dictionary keyed by sorted characters.

dicts strings anagrams
+10 pts 15m
Dicts & Sets easy

Common Keys of Two Dictionaries

Implement a function that finds keys shared by two dictionaries and returns them sorted.

dict set sorting
+8 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

Top k keys by count

Given a dictionary mapping keys to counts, return the top k keys with the highest counts, breaking ties alphabetically.

dictionary sorting frequency
+10 pts 15m
Dicts & Sets easy

Replace keys with a mapping

Write a function that renames keys in a dictionary according to a mapping, with duplicate handling.

dicts mapping transformation
+8 pts 10m
Dicts & Sets easy

Two Sum with Dict

Implement the classic Two Sum problem: return indices of two numbers that add up to a target using a dict.

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

Anagram Groups by Size

Group a list of words into anagram groups and return them sorted by group size and lexicographically.

dicts sets sorting
+10 pts 10m
Dicts & Sets easy

Top K Frequent Words

Given a list of words, return the k most frequent words sorted by frequency (descending) and then alphabetically.

dictionary sorting frequency
+10 pts 15m
Dicts & Sets easy

Sort by frequency

Sort a list by element frequency descending, with ties broken by order of first occurrence.

sorting frequency dictionaries
+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

Frequency sort descending

Write a function that sorts a list by frequency descending while preserving original order for ties.

frequency sorting dict
+10 pts 15m
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 medium

Hash map merge

Write a function that merges two dictionaries recursively, combining values and preserving structure.

dictionaries recursion merging
+15 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 hard

LRU cache decorator

Implement @lru_cache(maxsize=N) for unary functions using OrderedDict.

decorators caching OrderedDict
1
+50 pts 40m
Error Handling & Exceptions easy

Key error handler

Implement a safe dictionary access function that returns a default value on missing keys.

exceptions dict fallback
+8 pts 10m
Dynamic Programming medium

Word Break DP

Implement a function to check if a string can be segmented into space-separated dictionary words.

dynamic-programming strings word-break
+20 pts 25m
Trees & Binary Trees medium

Vertical Order Traversal

Compute the vertical order traversal of a binary tree, grouping nodes by column and row.

binary-tree bfs dictionary
+20 pts 25m
Graphs & Graph Algorithms medium

Alien Dictionary Order

Given a sorted list of words in an alien language, derive the order of its unique letters.

graph topological-sort string
+30 pts 30m

Showing 38 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.