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: every version of your code you've saved. You can rename, duplicate, or delete solution versions, or create a fresh one, 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.

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 the tests time out, your code was probably too slow or stuck in an infinite loop.

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 next to the problem statement, 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.

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 Submit Your Work dialog, which asks when you'd like to revisit the exercise. Submitting locks in your current solution (the editor becomes read-only) and takes you to the solution walk-through, where I walk through several approaches to the base problem and each bonus.

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 Submit Your Work 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