I need some help trying to delete non letter characters from strings in python (specifically, column names) but only the ones at the beggining and the end of the string.
Here it is so you can understand better what I am dealing with:
column_names = ['Column_1', 'Column_2_', '_Column_3__', '__Column_4___']
I need the output to be like this:
column_names = ['Column_1', 'Column_2', 'Column_3', 'Column_4']
Can you help me please?
>Solution :
You can do something like this ?
for i in range(0,len(column_names)):
column_names[i] = column_names[i].strip("_")
Strip also works if you specify which chars you want to strip (doc).