I am completely new to programming and only yesterday began to study python for scientific purposes.
Now I would like to split one very long line (174 characters) into several smaller ones, as shown below:
string = 'AA111-99XYZ ' split = ('AA', 11, 1, -99, 'XYZ')
Right now, the only thing I can think of is to use the slice x-times syntax, but maybe there is a more elegant way? Is there a way to use a list of integers to indicate split positions, for example.
split_at = (2, 4, 5, 8, 11) split = function(split_at, string)
I hope my question is not too stupid - I could not find a similar example, but maybe I just do not know what I'm looking for?
Thanks,
Jan
source share