# Anything you write here runs in YOUR browser.
# Press Run (or Ctrl + Enter) and change something.
def two_sum(nums, target):
seen = {}
for i, n in enumerate(nums):
if target - n in seen:
return [seen[target - n], i]
seen[n] = i
return []
print(two_sum([2, 7, 11, 15], 9))
print(two_sum([3, 2, 4], 6))
OutputLoading Python…
Press Run to see the output here. Whatever your program prints appears live.
Online Python compiler - free, no sign up
Write Python 3 and run it instantly in your browser. numpy, pandas and the standard library are here, input() works, and nothing is installed or uploaded.
How to run Python online
- 1. Pick Python from the bar on the left.
- 2. Write your code, or load one of the examples.
- 3. Press Run, or Ctrl + Enter.
- 4. Need input? Put it in the Input tab, one value per line.
Why it is safe to use
- • Your code runs inside your own browser, never on our servers.
- • Network access is switched off in the sandbox that runs it.
- • Nothing is uploaded, stored or shared unless you copy the link yourself.
Questions people ask
- Is this Python compiler really free?
- Yes - no account, no limit on how many times you run it, and no card.
- Can I use numpy or pandas here?
- Yes. Import them and they install themselves on the first run, inside your browser.
- Does input() work in this online Python compiler?
- Yes. Type the values into the Input tab, one line per input() call.
- Which Python version is this?
- Python 3.12, compiled to WebAssembly, so it behaves like the python3 on your machine.
- Where is my code saved?
- In your own browser. Nothing reaches our server, and the link button puts the code in a URL you can share.
