I have a string that looks like this:
1 | xxx | xxx | xxx | yyy*a*b*c | xxx
I want to expand the yyy*a*b*c
part so that the string looks like this:
1 | xxx | xxx | xxx | yyya | yyyb | yyyc | xxx
I actually have a big file with a delimiter between these strings. I have parsed the file into a dictionary that looks like this:
{'1': ['xxx' , 'xxx', 'xxx', 'yyy*a*b*c', 'xxx' ], '2': ['xxx*d*e*f', ..., 'zzz'], etc}
And I need to have that yyy*a*b*c
and xxx*d*e*f
part be replaced with additional items in the list.
How can I do this in python 3? Should I expand everything in the string before I parse it into a dictionary or after I parse it into a dictionary (and how)?
You can do this using split and simple list comprehension: