Python Playground
Write, run and debug real Python 3 in your browser, even offline.
Runs in your browser — nothing is uploaded
Hints
Show solution
Press Debug to record a run, then step through it.
Call stack
Variables
| Name | Type | Value |
|---|
Output so far
Real Python, in the page
This playground runs CPython 3.14 compiled to WebAssembly, so the language is exactly the Python you write everywhere else. Modern features are all here: structural pattern matching with match and case, async and await with asyncio.run and asyncio.gather, the walrus operator, dataclasses with slots, f-strings, type hints with the new generic syntax such as def first[T](items: list[T]) -> T and type aliases, and exception groups caught with except*.
Python runs in a background worker, so a slow program never freezes the page, and Stop ends even an infinite loop straight away. Each run starts from a clean slate, with no variables carried over from the last one.
Step through your code
Press Debug and the program runs once while every step is recorded. The editor highlights the line about to run, with the previous line shaded so you can see where execution came from. The call stack lists every active function, and selecting a frame shows its variables with their types and values. Values that changed since the last step are highlighted.
Because the whole run is recorded, you can step backwards as easily as forwards, which makes it easy to find where a value went wrong. Click beside a line number to set a breakpoint, then jump straight to it. For example, debug a recursive factorial(5) and watch five frames build up on the stack, then return 1, 2, 6, 24 and 120 as they unwind.
An editor that helps
The editor colours Python syntax, indents after a colon, matches brackets, folds blocks and supports multiple cursors, search and undo. Autocompletion comes from Jedi, the engine used by many Python editors: type "hello".up and it suggests upper with its signature and documentation, or from collections import de to get defaultdict and deque. Syntax errors are underlined as you type.
Copy and paste work as normal, and there are buttons to copy the code or the output, download your program as a .py file, or open one from disk. Your current code is saved in your browser automatically.
Good for practice
Use it to try out an idea, check how a built-in behaves, or practise for an interview with the Exercises menu, without installing anything. The Examples menu has short programs that show off each modern feature, and every one of them can be run or debugged as a starting point for your own.
Practise with exercises
There are 45 exercises in four groups. Beginner ones cover f-strings, list comprehensions, slicing, tuple unpacking, dicts, enumerate and zip, sets and splitting text. Intermediate ones cover function arguments, special methods, dataclasses, custom exceptions, generators, the collections module, sorting with key, closures, context managers and match statements. Advanced ones cover decorators, the iterator protocol, generics with Protocol, itertools, asyncio.gather, validated properties and exception groups. The Interview group has 20 classic problems in Easy, Medium and Hard, from two sum and valid parentheses to an LRU cache, course scheduling, Dijkstra's shortest paths and edit distance.
Check runs hidden unittest tests against your code and lists every test and subtest as ✓ or ✗ with its message. Interview problems state the complexity to aim for, and 12 of the 20 have a timing test on a large input that rejects an answer of the wrong complexity with a "Too slow" message. The timing check has a wide margin, so it catches the wrong complexity class, not small differences in speed — the exercises are for practice, not a proctored test. Solved exercises get a tick, and your code and progress stay in this browser.
How to use
- Type or paste Python, or pick an example.
- Press Run (Ctrl/Cmd+Enter) to see the output.
- Press Debug to step through the program and inspect variables.
- Open Exercises to practise: read the task, write the code, and press Check to run its tests — every test shows ✓ or ✗ with Python's own failure message.
FAQ
Is this real Python?
Yes. It is CPython 3.14, the standard Python interpreter, compiled to WebAssembly by the Pyodide project. The standard library is included, so modules such as json, re, datetime, dataclasses, itertools and asyncio behave exactly as they do on your machine.
Does it work offline?
Yes, after one visit. The first time you open the playground your browser downloads Python (about 8 MB) and keeps it. From then on the page, the editor, running, debugging, checking exercises and autocompletion all work with no connection. The status bar shows "Available offline" once everything is stored.
Is my code uploaded?
No. Your code runs in a background worker in this browser tab and is saved only in your browser's local storage so it survives a reload. Nothing is sent to a server.
How does the debugger work?
Debug runs your program once and records every step: the current line, the call stack and each variable's value. You can then step forwards and backwards, drag the slider to any point, or set breakpoints by clicking beside a line number and jump between them. Recording stops after 10,000 steps, so a loop that never ends still gives you a recording to step through. If a single step never finishes, such as one enormous calculation, press Stop to end the rest.
How do the exercises work?
Pick one of 45 exercises: 25 that practise Python itself, from list comprehensions and dicts to generators, decorators, asyncio and exception groups, and 20 classic interview problems, from two sum to Dijkstra's shortest paths. Each has a short task, starter code, hints and a reference solution. Check runs hidden tests written with Python's unittest module against your code and lists every test and subtest as passed or failed with Python's own message. Twelve of the 20 interview problems also time your answer on a large input, so a brute-force solution fails with a "Too slow" message that names the complexity to aim for. The timing check has a wide margin, so it catches the wrong complexity class, not small differences in speed or a slow device — the exercises are for practice, not a proctored test. Solved exercises get a tick, and your code for each one is saved in this browser, so you can come back to it later, even offline.
Can I install packages with pip?
No. The playground is designed to work offline, so it cannot download packages. Everything in the standard library is available.
How do I use input()?
Type the answers into the stdin box, one line per input() call, before you press Run. If the program asks for more lines than you provided, it raises EOFError and tells you to add more.
What doesn't work?
Anything that needs the operating system or the network: threads, multiprocessing, subprocesses, sockets and HTTP requests. Programs that never finish can be stopped with the Stop button.