Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Getting Started

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.

like image 612
user1345589 Avatar asked Apr 12 '26 06:04

user1345589


1 Answers

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').

like image 78
Taymon Avatar answered Apr 14 '26 19:04

Taymon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!