Peak Element in Array
Implement a function that returns the index of any peak element in a list of integers.
K Closest Elements
Implement a function to return the k closest elements to a target in a sorted array.
Online Stock Span
Implement StockSpanner.next(price) that returns the maximum number of consecutive days (including today) with price <= current price.
Jump Search
Implement the jump search algorithm to locate a target in a sorted list, returning its index or -1.
AST Visitor Lite
Implement a depth-first traversal of a simplified AST and return identifier names in order.
Merge time intervals
Given a list of time intervals, merge all overlapping intervals and return the merged intervals.
Top N per group
Implement top_n_per_group that returns the top N scores for each group from a list of (group, score) pairs.
Consecutive available seats
Given a list of seat statuses, return the length of the longest consecutive run of available (0) seats.
Argsort Indices
Implement a function that returns the indices that would sort a list of integers, with ties broken by original order.
Level Order Traversal
Implement a function that performs a level order traversal of a binary tree and returns node values as a list of lists.
Delete duplicates sorted II
Given a sorted list, remove duplicates in place so each element appears at most twice, returning the new length.
Accounts Merge
Given a list of accounts, merge those that share any email and return sorted accounts.
Strobogrammatic number II
Given a positive integer n, return all strobogrammatic numbers of length n in ascending order.
Once Decorator: Run a Function Only Once
Implement a decorator that caches and returns the result of the first call for subsequent calls.
Memoize with TTL
Implement a decorator that caches function results for a limited time, returning cached values within the TTL and recomputing after expiry.
Print Args Decorator
Write a decorator that prints function name and arguments, then returns the original result.
Log Calls Decorator
Create a decorator that prints call details and returns the original result.
Safe Integer from String
Implement safe_int that converts a string to an integer, returning a default value on any failure, with support for an optional base.
Safe divide function
Implement safe_divide that returns None on ZeroDivisionError and TypeError.
Safe int parser
Implement safe_parse_int that converts a string to an int, returning a default value on failure.
Safe Float Parser
Write a function that safely converts a string to a float, returning None for invalid inputs.
Key error handler
Implement a safe dictionary access function that returns a default value on missing keys.
Else on try block
Implement a function that uses try-except-else to safely divide two numbers and return a result or error description.
Parse JSON safely
Implement a robust JSON string parser that returns a fallback on invalid input.
Showing 169–192 of 371 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
- Pick a category — basics, algorithms, strings, and more
- Open a challenge, read the statement, and edit the starter code
- 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.