I am trying to split a string at a certain point using python
What I want to do is as follows:
let's say we have a string as
str = "123456789123456789"
I want to break this string in to parts where each part has a length of 5 or less (the last part)
so the output of the above string should look like this:
    l: 12345
    r: 67891
    l: 23456
    r: 789
This is my code I am trying to do this:
            errormsg = "123456789123456789"
            if len(errormsg) > 5 :
                print("yes")
                splitat = 5
                str = errormsg
                l, r = str[:splitat], str[splitat:]
                print("l: " + l)
                print("r: " + r)
                while len(r) > 5:
                    # print("hi")                
                    str = r
                    splitat = 5
                    l, r = str[:splitat], str[splitat:]
                    print("l: " + l)
                    print("r: " + r)
But it gives a weird output like this:
yes
l: 12345
r: 6789123456789
l: 67891
r: 23456789
l: 23456
r: 789
Can someone tell me how to fix this?
 
     
    