I am assuming that your string is sym and
- You want to remove all spaces from
sym
- Make a block (list) of words (strings) of length 5.
Python code in steps:
In [1]: sym = " !#$%^&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~" #This is your input string
In [2]: sym = sym.replace(" ","") #remove all "" (spaces)
In [3]: sym #Lets check the output
Out[3]: "!#$%^&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{}~"
In [4]: sym_list = [ sym[i:i+5] for i in range(0, len(sym), 5)] # use range to generate iteration with increment 5 each time
In [5]: sym_list #So, did we get blocks of 5 chars? hope so.
Out[5]:
['!#$%^',
"&'()*",
'+,-./',
'01234',
'56789',
':;<=>',
'?@ABC',
'DEFGH',
'IJKLM',
'NOPQR',
'STUVW',
'XYZ[\\',
']^_`a',
'bcdef',
'ghijk',
'lmnop',
'qrstu',
'vwxyz',
'{}~']
Correct me if any of my assumptions are incorrect.