-1

Extremely new to this so this is likely caused by my own inexperience, so apologizing in advance here. I know this is said a lot on these questions but I'm trying to learn python using 'Learn python the hard way.'. I've become stuck on exercise 1: http://learnpythonthehardway.org/book/ex1.html

On windows we have to create a text file in notepad ++ called 'ex1.py' and run it in PowerShell using the command 'python ex1.py'.

Problem is every time I try, I get this error:

File "ex1.py", line 1

   Print "Hello World!"
                      ^
SyntaxError: invalid syntax

These types of errors are mentioned on the tutorial page but it only explains they point out errors and to use what it says in the 'SyntaxError:' to search for the answer if what it says is too cryptic to understand. Why is the caret pointing towards the "? What am I doing wrong?

Any help would be greatly appreciated by this newbie.

davidism
  • 121,510
  • 29
  • 395
  • 339
  • `print("Hello World!")` python3 vs python2 print statements – sshashank124 Jun 25 '14 at 13:50
  • 4
    You are using `Print`, not `print`. Case matters! Python cannot detect that you made the error until the next token is complete (at the end of the string), as the name `Print` could be combined with some other operator (`Print + "Hello World!"` would be legal Python syntax). – Martijn Pieters Jun 25 '14 at 13:51
  • Remember to read the every little detail, and pay attention to the WYSS section. – Vladimir Putin Jun 25 '14 at 13:53
  • Jesus, you guys are quick! Thanks a lot everyone, didn't even noticed I used upper cases, gotta get better at spotting the difference. Thanks again and not for getting mad at my stupid mistake! – user3775352 Jun 25 '14 at 13:58

2 Answers2

4

Python is a case-sensitive language. print needs to be lowercase:

print "Hello World!"

If you are using Python 3.x, you also need parenthesis because print is a function:

print("Hello World!")
  • Thanks for helping me with my silly mistake! New to this site, should I leave this up for other people or delete the post? – user3775352 Jun 25 '14 at 14:03
1

You have a syntax error because Print should be print.

davidism
  • 121,510
  • 29
  • 395
  • 339
sundar nataraj
  • 8,524
  • 2
  • 34
  • 46