How can I strip first and last double quotes?


I want to strip double quotes from:

string = """ " " ""1" " "" """

to obtain:

string = "" " " ""1" " "" ""

I tried to use rstrip, lstrip and strip("[^"]|["$]") but it did not work.

How can I do this?

Answer rating: 203

If the quotes you want to strip are always going to be "first and last" as you said, then you could simply use:

string = string[1:-1]

Get Solution for free from DataCamp guru