[Tutor] Extract Names from string
nathan Smith
nathan-tech at hotmail.com
Tue Aug 3 09:29:08 EDT 2021
So if I've understood this right you'd have a list of elements like this:
st="\"hydrogen\", \"helium\""
That being the case could you not just do something like:
splitted=st.split(",")
for x in range(len(splitted)):
splitted[x]=splitted[x][1:-1]
And there you have it?
A list of names without quotes?
Nathan
On 03/08/2021 14:08, Stephen P. Molnar wrote:
> I have a project which generates a large number of data files and have
> pyhon scrip;t that does most of the pre- and post-processing. However,
> I have one problem which has not succumbed to Googling.
>
> I have a list of chemical names which I can load as a string of the form:
>
> "name1","name2", . . .
>
> Unfortunately, the names are not the same length which precludes
> extracting each name by indexing.
>
> My question is ho w to extract individual names?
>
> Thanks in advance.
>
More information about the Tutor
mailing list