3 Replies - 1237 Views - Last Post: 26 January 2010 - 07:01 AM Rate Topic: -----

#1 ladyinblack   User is offline

  • D.I.C Regular
  • member icon

Reputation: 9
  • View blog
  • Posts: 419
  • Joined: 08-April 09

Beginning Python

Post icon  Posted 26 January 2010 - 03:58 AM

I'm attempting to do the 4th challenge. I'm having a problem with the print command.

I'm working with a tutorial that I downloaded from the python site. And at first, I used the command prompt. Then, today I notice that the installation file comes with a python shell. So, while working with both, the beginning of the tutorial seems easy, working with numbers, then come the string part of the tutorial.

This is what happens:

Quote

>>> print "Hello"
SyntaxError: invalid syntax (<pyshell#57>, line 1)
>>>


Any ideas or suggestions?

Is This A Good Question/Topic? 0
  • +

Replies To: Beginning Python

#2 dorknexus   User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1272
  • View blog
  • Posts: 4,625
  • Joined: 02-May 04

Re: Beginning Python

Posted 26 January 2010 - 04:34 AM

If you are using the latest python (3.x) then print is now a function instead of a keyword so you must use parenthesis like so:

print("Hello")

Was This Post Helpful? 1
  • +
  • -

#3 chemicalfan   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 16-October 09

Re: Beginning Python

Posted 26 January 2010 - 05:18 AM

It almost sounds like you're using a Python 2.6 tutorial with a Python 3.0 interpreter - this won't go well!
Was This Post Helpful? 0
  • +
  • -

#4 ladyinblack   User is offline

  • D.I.C Regular
  • member icon

Reputation: 9
  • View blog
  • Posts: 419
  • Joined: 08-April 09

Re: Beginning Python

Posted 26 January 2010 - 07:01 AM

Thanks, I forgot to mention I'm using Python 3.1.

Problem solved.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1