check length of input string with if stri.len > 3 On Sun, Jun 5, 2011 at 8:35 PM, Ganapathy Subramanium < sganapathy.subraman...@gmail.com> wrote:
> 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 > > -- Nitin Pawar
-- http://mail.python.org/mailman/listinfo/python-list