0

I'm new to Python and I created my first piece of code which is simply

print('Hello World!')

and it works fine and I named it hello.py. When I try to open the file it says with "python hello.py"

I get an error message that says

File "hello.py", line 1 PYthon 3.4.4 (v3.3.3:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1.600 64 bit (AMD65)] on win32

SyntaxError: invalid syntax

I added Python to the PATH so I don't know what's the issue

4
  • How did you save it (with what editor)? You're on Windows and I guess that the ^M can upset you. Commented Jan 1, 2016 at 6:44
  • 2
    Seems like you typed it all by hand (AMD65 LOL) Commented Jan 1, 2016 at 6:45
  • 1
    Please paste the exact text from the command prompt, including the command line that you're running. Commented Jan 1, 2016 at 6:47
  • you should learn what the command line is and how to run python in it. Commented Jan 1, 2016 at 9:57

1 Answer 1

2

You're not supposed to put those lines into your script. They come from the interpreter, giving information to you. You're only supposed to include in your script the commands that you want to give to the interpreter. In your case, your hello.py file should consist entirely of this:

print('Hello World!')

and nothing else.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.