Jump to content


Photo

Ch.2, Pg. 56 - Tab Stop


  • Please log in to reply
5 replies to this topic

#1 njordan2001

njordan2001

    New Member

  • Members
  • Pip
  • 4 posts

Posted 05 February 2012 - 11:36 AM

print("\t", end='')

This is not working!! I'm getting this error:
  File "pg56.py", line 8
    print("\t", end = ' ')
                    ^
SyntaxError: invalid syntax

Any ideas, PLEASE??!!

#2 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 05 February 2012 - 11:52 AM

You will typically see this error if you are using Python 2 instead of Python 3. Make sure you are running the code in Python 3.

Hope this helps.

Paul.

#3 njordan2001

njordan2001

    New Member

  • Members
  • Pip
  • 4 posts

Posted 05 February 2012 - 12:16 PM

You will typically see this error if you are using Python 2 instead of Python 3. Make sure you are running the code in Python 3.

Hope this helps.

Paul.


Thank you Paul! And thanks for the quick response!

I was running 2.7.1, based on an online tutorial's suggestion.... I'm thinking I might have to go back to the start of the book and re-read, paying more attention to information about using IDLE.

Thanks again Paul!

#4 Cici_Dong

Cici_Dong

    New Member

  • Members
  • Pip
  • 2 posts

Posted 08 September 2013 - 06:57 PM

You will typically see this error if you are using Python 2 instead of Python 3. Make sure you are running the code in Python 3.

Hope this helps.

Paul.



Hi Paul,

If I have to use Python 2.7, is there anything can replace the 'end=' '' for the same purpose?
And also in Chapter 4, P112, for the code 'print(man, file=man_file), same syntax error for 'file=man_file'. Any solution for this in Python 2.7?
I believe the function for writing data to a file is very basic, and should be applied at the beginning of the Python version right?

The reason for me to use Python 2.7 is the project i'm working on. It's Client's wish, so....
Looking forward to hear from you, thanks Paul!

Thanks,
Cici Dong

#5 Cici_Dong

Cici_Dong

    New Member

  • Members
  • Pip
  • 2 posts

Posted 08 September 2013 - 06:58 PM

You will typically see this error if you are using Python 2 instead of Python 3. Make sure you are running the code in Python 3.

Hope this helps.

Paul.



Hi Paul,

If I have to use Python 2.7, is there anything can replace the 'end=' '' for the same purpose?
And also in Chapter 4, P112, for the code 'print(man, file=man_file), same syntax error for 'file=man_file'. Any solution for this in Python 2.7?
I believe the function for writing data to a file is very basic, and should be applied at the beginning of the Python version right?

The reason for me to use Python 2.7 is the project i'm working on. It's Client's wish, so....
Looking forward to hear from you, thanks Paul!

Cici

#6 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 09 September 2013 - 12:26 PM

At the top of your program, please add:

from __future__ import print_function

That should do it!

--Paul.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users