Python Playground
Fix a small Python puzzle or write your own code. Run it in your browser and see the output.
PYTHON / LEARN BY TRYING
Change the code, see what happens
Start with a small bug. Edit the Python, run it, and use the results to work out what to try next.
YOUR TASK
Fix the positive-number filter
This function should add only numbers greater than zero. Find the incorrect condition, change it, and run the code to check your fix.
Look at the comparison inside the loop. Which side of zero should count toward the total?
Use four spaces to indent. Ctrl+Enter or ⌘+Enter runs the code.
Press Run Python to execute your code. The first run loads Python into this tab.
For the starting example, a correct function should print 13.
Check the behaviour
Run the code to check 4 examples, including an empty list.
Your input stays in this tab. These tools do not upload, store, or send it to an AI service.