# python 3.2.2 invalid syntax

Page 1 of 1

## 9 Replies - 7149 Views - Last Post: 09 January 2012 - 07:18 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=253041&amp;s=c0fbd84240b862ad9b11c9b7853fb975&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 staivewhore

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

# python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:02 PM

HI!

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

• Blue Sprat

Reputation: 319
• 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.

### #3 staivewhore

Reputation: 0
• 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.

### #4 Motoma

Reputation: 452
• 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.

### #5 Simown

• Blue Sprat

Reputation: 319
• 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

### #6 Motoma

Reputation: 452
• 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!

### #7 staivewhore

Reputation: 0
• 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!

### #8 Simown

• Blue Sprat

Reputation: 319
• Posts: 650
• Joined: 20-May 10

## Re: python 3.2.2 invalid syntax

Posted 26 October 2011 - 06:57 PM

@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.

### #9 Eddie_Nygma

Reputation: 1
• 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.")

Eddie_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.")

### #10 Motoma

Reputation: 452
• 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 "(".