I assume you are running and editing your notebook in a browser. You can export it via:
File -> Download as -> Python (.py)

Alternatively you might use
jupyter nbconvert --to script your_notebook.ipynb