Solving exercises in your browser

Once you've claimed an exercise, you can solve it entirely in your browser: write your code, run the tests, and read the solution walk-through, all without installing anything.

Prefer working in your own editor? That works too: see Testing Exercises Locally.


The solve page

The solve page has three tabs:

  • Your Code: the editor where you write your solution
  • Tests File: the automated tests your code will be checked against (read-only)
  • Test Failures: details on any tests that failed during your last test run

Next to the tabs you'll find Test Results, showing a row for the base problem and each bonus, color-coded by whether its tests passed.

The sidebar also lists Your Solutions: the versions of your code for this exercise. Save and Test updates the version you're working on; a new version only appears when you create a new solution or duplicate an existing one. You can rename, duplicate, or delete solution versions, which is handy for trying a different approach without losing your first one.


Running the tests

Click Save and Test (or press Ctrl+S) to save your code and run the tests.

Your code is saved when you save and test, not continuously as you type. If you see a * next to the "Your Code" tab, you have changes that haven't been saved yet, so save before closing the page.

Python runs right in your browser, and the badge on the editor shows which version of Python it is. The first test run on a page may take a moment, since your browser has to download Python first.

A few limitations to know about:

  • Only the Python standard library is available: no third-party modules like requests.
  • input() calls aren't supported by the test runner (the tests provide all the input your code needs).

If something goes wrong:

  • The button stays on "Testing..." and never finishes. Your code is probably stuck in an infinite loop or very slow. Copy your code, reload the page, fix the loop, and test again: the changes from that run weren't saved.
  • "Could not load Python." Your browser couldn't download Python. Check your connection and try again.
  • "Python stopped unexpectedly." Click Save and Test again.
  • A red error under the editor. If your code has a SyntaxError or a misspelled import, it fails before any test runs, so the error shows under the editor rather than as a test failure.

How bonuses work in the browser

Most exercises have a base problem plus one or more bonuses. When you save and test in the browser, all tests run every time: the base problem and every bonus. There's nothing to enable or comment out (commenting out lines in the tests file is only needed when testing locally).

You don't need to solve every bonus. Bonuses that aren't recommended for your skill level appear collapsed in the problem statement and greyed out in the Test Results panel. Solving just the recommended parts counts as solving the exercise, and you can always revisit later to attempt more.


Stuck? Use the hints

If an exercise has hints, you'll see a Hints panel in the sidebar under Test Results, with hints grouped by part (base problem, bonus 1, and so on).

Hover over a hint for a quick nudge, or click it for more help: each hint links to a screencast, article, or other resource about the technique you might need. Using hints isn't cheating: it's how the exercises are meant to work when you're stuck.


Understanding test failures

The Test Failures tab shows the traceback for each failing test, grouped by base problem and bonus. The tracebacks are interactive: click a test name or a line reference to jump to that spot in the tests file.

Under each failure you'll also find an Explain this test failure button. It uses AI to explain what the failing test was checking and why your code might not satisfy it, without giving away the answer. Like all AI-generated text, the explanation may not be completely accurate, but it's often a helpful nudge.


What about debugging with print?

The Test Failures tab shows tracebacks rather than your program's printed output, so print() calls aren't a great debugging tool on the solve page.

Instead, try:

  1. Reading the failing test. Click through from the traceback and look at exactly what input the test passed in and what output it expected.
  2. Asking for an explanation. The "Explain this test failure" button is good at translating an assertion error into plain English.
  3. Experimenting elsewhere. Paste your code into the Python Morsels pastebin and run it there, where you can see printed output, or download the tests and debug locally where print and debuggers work normally.

Think a test is wrong?

If a test seems wrong, too strict, or the problem statement has a typo, click Leave feedback in the solve page's sidebar and check the "Found a typo or another issue?" box. That feedback comes straight to me.


Submitting your work and reading the solutions

I recommend setting a timer (say, 25 minutes) for your attempt. When your time is up, click Read the solutions, even if you didn't get as far as you'd like. This is your F.A.I.L. attempt: your First Attempt In Learning.

Clicking the button opens a Reveal the solutions dialog, which asks when you'd like to revisit the exercise. Revealing the solutions locks in your best-scoring solution (it becomes read-only) and takes you to the solution walk-through, where I walk through several approaches to the base problem and each bonus. You can still duplicate a locked solution if you'd like to keep tinkering with it.

At the bottom of the walk-through page you'll find a learning reflection form. Taking two minutes to note what you recalled, what you forgot, and what you discovered is one of the highest-value habits on Python Morsels.


Revisiting an exercise later

Revisiting is how Python Morsels helps things stick: solving an exercise again from scratch a few weeks later is one of the most effective ways to cement what you learned.

You can schedule a revisit from the Reveal the solutions dialog or from the solution walk-through page, and revisiting temporarily hides your old solutions until you lock in again. For the full story, see Revisiting Exercises.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us