Please help, I'm getting invalid syntax when trying to print

This is the place for queries that don't fit in any of the other categories.

Please help, I'm getting invalid syntax when trying to print

Postby allanfullerton » Fri Jul 19, 2013 2:36 am

Hello, I'm completely green at this and am working my way through the book "Think Python". There is a code in there showing "Parameters and Arguments" as follows...

Code: Select all
def print_twice(bruce):
      print bruce
      print bruce

When I try to run this, it brings up an "invalid syntax" error, with the second instance of bruce highlighted in red. I don't understand why this wouldn't work, especially as it's straight out of the book.
Any thoughts? Thanks.
Last edited by Yoriz on Fri Jul 19, 2013 5:43 am, edited 1 time in total.
Reason: Added code tags and changed title.
Posts: 1
Joined: Fri Jul 19, 2013 2:30 am

Re: Mega-noob question!

Postby metulburr » Fri Jul 19, 2013 3:28 am

use code tags to preserve python's indentation.

It could be a conflict of python version where:
python2.x is :
Code: Select all
print "var"

and python3.x is :
Code: Select all
we will be moving to on October 1 2016
more details here
User avatar
Posts: 2244
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 3 guests