Downloading Jupyter Notebooks

When I try to download a Jupyter notebook as a .py file, it downloads as .html. What can I do about this?

I think browser is forcing html type extension on the file because it detects some HTML code inside cell 1 and 2.
Even though the file is downloaded as HTML file, it still is a Python file - just change the extension from .html to .py.
Or, when you get the download prompt, try changing the file extension and wrap the whole name in double-quotes to prevent browser from adding another extension at the end, i.e. “Optimization_methods.py”