"Bill DeBroglie" <bill.debrog...@gmail.com> wrote

Using Mac OS X 10.5.8 and Python 2.7.1 but am following a book which is using Python 3.1.

In 2.7 there should be a way to get print() to work like 3.1...

The author uses the end parameter in numerous programs but this doesn't seem to translate to 2.7. Any advice as to how I can specify the final string of the print function?

In general terms you need to use string formatting or catenation
to add the appropriate end string. In the most common case of
simply suppressing the newline just add a comma:

v3.1 # suppress newline
print(spam end='')
v2.x
print spam,

v3.1 # add arbirary postfix
print(value, end=' cents')
v2.x
print value, " cents",

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to