Make string length divisible by 6 in Python
Question: I want the program to take a users input and format its length so it is
divisible by six, by adding the characters of the string onto the end of the
string, until `len(string)%6 == 0`:

    
    
    string = raw_input('Enter String')
    while len(string)<=6-len(string)%6 and len(string)%6 != 0:
            print 6-len(string)%6
            string = string + string
    while len(string)%6 != 0:
        string = string + string[0::6-(len(string)%6)]
    
    print string
    

Examples (using numbers as a stand in for whatever character could be situated
at that point):

    
    
    1 -> 111111 
    12 -> 121212
    123 -> 123123
    1234 -> 123412
    12345 -> 123451
    12456 -> 123456
    1234567 -> 123456712345
    

I am getting stuff like this:

    
    
    12 -> 121211
    12345 -> 123451234513524142551545411111
    


Answer: You could try something like this (code written/tested in Python 3.4):

    
    
    import itertools
    
    lStr = input("Enter string:")
    
    def getStrMod(aStr, aMod):
        lIter = itertools.cycle(list(aStr))
        while len(aStr) % aMod != 0:
            aStr += next(lIter)
        return aStr
    
    print(getStrMod(lStr, 6))
    

Results:

    
    
    Enter string:1
    111111
    
    Enter string:12
    121212
    
    Enter string:12345
    123451
    
    Enter string:1234567
    123456712345
    

