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

Absolute Difference of Two Integers

Compute the absolute difference between two integers, regardless of order.

absolute difference math
+5 pts 5m
Python Basics easy

Swap Two Values

Implement a Python function that swaps two given values and returns them in swapped order.

variables assignment swap
+5 pts 5m
Strings & Text easy

Reverse a string

Return the characters of the string in reverse order.

strings slicing
+5 pts 5m
Strings & Text easy

Extract Digits Only

Given a string that may contain letters, symbols, and whitespace, extract all digits in order and return them as an integer.

strings digits parsing
+5 pts 5m
Strings & Text easy

Reverse Words in a Sentence

Reverse the order of words in a sentence while preserving single spaces between words.

strings split reverse
+10 pts 15m
Strings & Text easy

Extract digits from string

Write a function that extracts all digit characters from a given string, preserving their original order.

strings digits parsing
+6 pts 8m
Strings & Text easy

Extract Hashtags

Extract unique hashtags from a given text string in the order they appear.

strings parsing hashtags
+10 pts 15m
Lists & Arrays easy

Move Zeros to the End

Reorder a list in-place, pushing all zeros to the end while preserving the order of non-zero numbers.

lists in-place two-pointer
+10 pts 15m
Lists & Arrays easy

Interleave Two Lists

Write a function that interleaves two lists element by element, preserving order.

lists merge indexing
+10 pts 10m
Lists & Arrays easy

All Unique Values Keep Order

Remove duplicates from a list, keeping only the first occurrence of each value while preserving relative order.

deduplicate order list
+10 pts 15m
Lists & Arrays easy

Move Zeros to End

Rearrange a list by moving all zeros to the end while preserving the relative order of non-zero elements.

list in-place two-pointer
+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

Wave sort array

Given a list of integers, reorder it into a wave pattern where elements alternate down-up, and return the new list.

sorting swap rearrangement
+10 pts 15m
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

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

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

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

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
Data Structures & Algorithms easy

Valid parentheses

Return True if brackets in the string close in the correct order.

stack strings
+15 pts 14m
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 easy

Bubble Sort

Implement bubble sort that sorts a list of numbers in ascending order.

sorting arrays algorithms
+8 pts 12m
Data Structures & Algorithms easy

Selection Sort Implementation

Implement selection sort to sort a list of numbers in ascending order.

sorting selection-sort algorithm
+10 pts 15m
Iterators & Generators easy

Tree inorder generator

Write a generator function that yields a binary tree's node values in inorder traversal.

generator inorder binary-tree
+10 pts 15m
Math & Number Theory easy

Partition function

Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).

math recursion memoization
+12 pts 15m
Trees & Binary Trees easy

Binary Tree Inorder Traversal

Implement an inorder traversal function that returns node values in left-root-right order.

binary-tree traversal recursion
+10 pts 15m
Trees & Binary Trees easy

Preorder Traversal

Implement a function that returns the preorder traversal values of a binary tree.

binary-tree traversal recursion
+10 pts 10m
Trees & Binary Trees easy

Postorder Traversal

Implement a function that returns the postorder traversal of a binary tree as a list of node values.

binary-tree traversal recursion
+10 pts 15m

Showing 29 challenges · easy

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.