9 Replies - 6030 Views - Last Post: 09 January 2012 - 07:18 AM Rate Topic: -----

#1 staivewhore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-October 11

python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:02 PM

HI!

Ive just downloaded Python 3.2.2 for some school revision,
heres the code we've been using in class, as soon as i f5 it, i get prompted with invalid syntax.

when it prompts the 2 in this title gets highlighted red.....do i have the wrone version or something?
Python 3.2.2 (default, Sep 4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win32
^

>>> #variables
>>> secondsInAMinute = 60
>>> minutesInAHour = 60
>>>
>>> #calculate the results
>>> secondsInAHour = secondsInAMinute * minutesInAHour
>>>
>>> #display the output
>>> print("there are", secondsInAHour,"seconds in an hour")

thanks, jim

Is This A Good Question/Topic? 0
  • +

Replies To: python 3.2.2 invalid syntax

#2 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:10 PM

Are you typing the code with the ">>>" before it?

If you enter IDLE, File -> New Window
Type in all the code you had previously, without the ">>>"s
Then save the code
And go Run -> Run Module (or press f5)

And it should work. You don't have the wrong version, no.
Was This Post Helpful? 0
  • +
  • -

#3 staivewhore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-October 11

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:26 PM

Hi Simown, thanks for the reply,

the >>> comes up everytime i hit enter for a new line.

im still having issues, I opened up a new idle and wrote this:

>>> print ("helloworld")

saved it, hit f5, same problem - invalid syntax and the 2 in the title gets highlighted again.
Was This Post Helpful? 0
  • +
  • -

#4 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:33 PM

Post the full error message, verbatim, please.
Was This Post Helpful? 0
  • +
  • -

#5 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:36 PM

You are typing your program in the wrong place, it seems.

Don't type in the first window IDLE opens:

Click File -> New Window
Type your program in the blank window (>>> won't come up for new lines)
Save it, and then run it.

The window with the >>> is the Python interpreter, not where you write programs.

@Motoma He is saving the prompt window, which you seem to be allowed to do. Not a new blank window.

This post has been edited by Simown: 26 October 2011 - 06:38 PM

Was This Post Helpful? 2
  • +
  • -

#6 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:44 PM

Boy, that's interesting.
Good find Simown!
Was This Post Helpful? 0
  • +
  • -

#7 staivewhore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-October 11

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:48 PM

it says Invalid syntax
thats it. >.<

ignore the above post of mine,

WOOHOO Simown was spot on!
ive got it under control now, thanks for the help guys appreciate it!
Was This Post Helpful? 0
  • +
  • -

#8 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:57 PM

Great :) Glad it works.

@Motoma It makes kind of sense to be able to save the shell, to show people perhaps, but it will never give valid syntax when you run it. Very strange.
Was This Post Helpful? 0
  • +
  • -

#9 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Re: python 3.2.2 invalid syntax

Posted 09 January 2012 - 01:36 AM

What's up everyone this is my introductory post, you may call me Riddler. I have been having this exact problem with idle 3.2.2, but it's on Fedora 16, so this is obviously not a platform soecific bug we're dealing with here. Is there any way the error can simply be configured to ignore it, or what should be done? This is the second language I've tackled, I first learned Java, am pretty good at witing shell scripts, and am learning Python for a computer science class, although I've been practicing with Python Programming for the Absolute Beginner by Michael Dawson. It's a pretty simple text-based program and I can't get it to run:
 
# Fancy Credits
# Demonstrates escape sequences

print("\t\t\tFancy Credits")

print("\t\t\t \\ \\ \\ \\ \\ \\ \\")
print("\t\t\t\tby")
print{"\t\t\tEdward Nygma")
print("\t\t\t \\ \\ \\ \\ \\ \\ \\")

print("\nSpecial thanks goes out to:")
print("My hair stylist, Henry \'The Great.\' who never says \"can\'t.\"")

# sound the system bell
print("\a")

input("\n\nPress the enter key to exit.")      


View PostEddie_Nygma, on 09 January 2012 - 01:34 AM, said:

What's up everyone this is my introductory post, you may call me Riddler. I have been having this exact problem with idle 3.2.2, but it's on Fedora 16, so this is obviously not a platform soecific bug we're dealing with here. Is there any way the error can simply be configured to ignore it, or what should be done? This is the second language I've tackled, I first learned Java, am pretty good at witing shell scripts, and am learning Python for a computer science class, although I've been practicing with Python Programming for the Absolute Beginner by Michael Dawson. It's a pretty simple text-based program and I can't get it to run:
 
# Fancy Credits
# Demonstrates escape sequences

print("\t\t\tFancy Credits")

print("\t\t\t \\ \\ \\ \\ \\ \\ \\")
print("\t\t\t\tby")
print("\t\t\tEdward Nygma")
print("\t\t\t \\ \\ \\ \\ \\ \\ \\")

print("\nSpecial thanks goes out to:")
print("My hair stylist, Henry \'The Great.\' who never says \"can\'t.\"")

# sound the system bell
print("\a")

input("\n\nPress the enter key to exit.")      

Was This Post Helpful? 0
  • +
  • -

#10 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: python 3.2.2 invalid syntax

Posted 09 January 2012 - 07:18 AM

Your error message should point at the exact problem:

File "test.py", line 8
    print{"\t\t\tEdward Nygma")
         ^
SyntaxError: invalid syntax



The character you have typed here is a curly bracket "{", not a parenthesis "(".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1