I’ve got a long string object which has been formatted like this
myString = “[name = john, family = candy, age = 72],[ name = jeff, family = Thomson, age = 24]”
of course the string is longer than this.
Also i have 3 lists with related names:
Names = []
Families = []
Ages = []
I want to read that string character by character and take the data and append it into appropriate lists. Can anyone help me on this about how to separate the string into variables?
The thing I need is something like this:
Names = [“john”, “jeff”, ...]
Families = [“candy”, “Thomson”, ...]
Ages = [72, 24, ...]
This can be most easily done using a regex. Basically, construct a regex that extracts the name,family and age from the string and extract the relevant data from the
tuples returned to build yourlists.