Hi All,

I'm a new bie to programming and need some assistance in this code.

I have a function which will split the given string into 3 characters each
and I want to achieve this by recursion.

I have written the following code, but I don't know how to stop the
recursion when the length of the remaining string is less than or equal to 3
characters. Any inputs on this please?

string = 'This is a sample python programming'
space = 2
final_result = []
def strsplit(stri, spa):
    s = stri[:spa]
    final_result.append(s)
    stri = stri[spa:]
    strsplit(stri,spa)
    return final_result
c = strsplit(string,space)
print 'The final result is: ', c
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to