I've a list with only one element, which in itself is a list of elements.
str = '"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL"'
Now, I want each individual name in that string to included in another list. For that, I understand that I have to split each name individually and then append them with the desired list. Here's the code I wrote for the same:
str = '"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL"'
li = str.split()
c = li[0]
ip = []
start = c.find('"')
final = c.find('"', start+1)
def iter(start, final):
e = c[start+1:final]
ip.append(e)
nstart = c.find('"', final+1)
nfinal = c.find('"', nstart+1)
if(nstart == -1 or nfinal == -1):
print ip
else:
iter(nstart, nfinal)
However, I don't get anything as output. 'ip' is the list where I intend to store all the names, individually. What seems to be the problem with my code?
namelist = nameStr [1:-1].split('","')?