Hi I'm teaching myself python, have downloaded 3.4 and am working through Think Python. The problem i'm having is printing a grid. I won't put the whole code up but the bit that is a problem.
def do_twice(f):
f()
f()
def print_beam():
print("+ - - - - ", )
def print_beams():
do_twice(print_beam)
print("+")
now this when called is supposed to print a beam like this + - - - - + - - - - +
However, the actual output is
+ - - - -
+ - - - -
+
I've spent a good two hours on this but the version of python i'm using is different from the book I'm working on. Could anyone help me out of this log jam?
import sys; print(sys.version)printstatement in order to suppress a newline, then it's almost certainly written for 2.7 or lower. I assume that's why you've got a stray comma in yourprint_beamfunction?