2

I am just getting started with Python and wrote a simple perimeter program. However whenever I type python perimeter.py in my terminal I get the following error I don't know how to solve it.

>>> python perimeter.py
File "<stdin>", line 1
python perimeter.py
               ^

SyntaxError: invalid syntax

What is that problem? How do I fix it?

Thanks.

1 Answer 1

9

You type python perimeter.py in your command shell to start the Python interpreter. You don't type it in the Python interpreter.

If you really need to run the script from within the Python interpreter, do execfile('perimeter.py').

Sign up to request clarification or add additional context in comments.

2 Comments

@tekknolagi: If you remove the .py, that may work the first time, but not any subsequent times.
Ah, whoops. import perimeter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.