print
and return
are very different.
Print is a function that will just print out something to the screen. return is a command that basically tells what value a function should return. For example:
def func1():
print 1
def func2()
return 2
if you do
first_result = func1()
second_result = func2()
you will see that
first_result = None
second_result = 2
but if you run them
func1()
func2()
you'll see that only 1
will be printed to the screen. In order to print the return of a function, you have to explictly ask for it
print func2()
With that in mind, and heading to your problem, you can store your things and return that to the function, and just then ask for python to print everything out
def func3():
b = 'abbaab'
count = 0
width = 2
things = []
for k in range(0, len(b), width):
things.append(b[k:k + width])
return things
print func3()
Of course in this csae, you will print all values at once. In order to print each line separately, iterate the result and print each element
value_returned = func3()
for element in value_returned:
print element