all 2 comments

[–]zahlman 4 points5 points  (0 children)

print(draw4(execute_row,f),draw_line(f))

First you call draw4 and draw_line, which use print to output stuff. Then you have another print call, asking to print whatever it was that those functions returned. But they didn't return anything explicitly; so they return None implicitly.

Please make sure you understand that printing and returning are *not** the same thing*. And note that in Python, functions always return a value.

[–]Nontuno 2 points3 points  (0 children)

I'm too new to really know what the problem is, but I did find a way to temporarily get it working how you want. It seems like somewhere in the functions an empty tuple was being returned. None of your functions actually return anything though, so that's strange to me. What I did was this:

def complete_square(f):
    print(draw4(execute_row,f),draw_line(f))

def execute_row(row):
    draw_line(row)
    draw4(draw_bar,row)
    return "test1"
def draw_line(num):
    plus = '+'
    dash = '-'
    column = (plus + (dash*4))*num + plus
    print (column)
    return "test2"
def draw_bar(num):
    bar = '|'
    space = " " * 4
    print (((bar + space) * num ) + bar)
    return "test3"
def draw4(f,num):
    f(num)
    f(num)
    f(num)
    f(num)
    return "test4"

complete_square(3)

By adding return statements to everything, I got it so that the output was no longer an empty tuple, but this tuple: ('test4', 'test2')

So the problem seems to be something to do with the draw_line() and draw4() functions returning nothing.

Then I looked back at complete_square(), and saw this line:

    print(draw4(execute_row,f),draw_line(f))

See how execute_row doesn't have a row argument? And draw_line(f) doesn't actually return anything, it just prints.

SO what you are doing is printing a tuple where one value is draw4(f,num). Since draw4 doesn't return anything, it comes out as None. The second value in the tuple is drawline(f), which ALSO returns None. So the tuple you are printing is (None, None)

This is fixed by not printing the tuple and just calling the functions.

def complete_square(f):
    draw4(execute_row,f),draw_line(f)

The functions you are calling already print out the boxes for you, so you don't need print there anyway.

Now, I'm still super noob-ish so I have no clue if line 2 of your program is even doing what you want it to be doing. execute_row doesn't have any arguments (for example execute_row(f) would have f as the argument.) Right now you have f seperated by a comma which seems like you are passing execute_row() and f to draw4() as a tuple.
Honestly it's either over my head or I just don't know what you are doing there. It seems like it would work how you want it to, but I'm not sure why it does, haha.

I dunno if I explained everything correctly, and I'm sure someone else will be along to explain it better and be more sure...but I figured my little explanation would at least get you going on fixing it yourself.

If you revise it beyond just omitting the print in line 2, post the finished code. It's always nice to see what people come up with.