Answer by user16836078 for How to strip/remove certain characters from a list
You can use map to remove the strings too if you don't want to do list comprehension.list(map(lambda x:x.replace('_out',''),lst1))Out[136]: ['ZINC1.pdbqt', 'ZINC2.pdbqt', 'ZINC3.pdbqt']To see the...
View ArticleAnswer by Jeffrey Zang for How to strip/remove certain characters from a list
The problem with your code right now is that you are trying to strip the list, not the attribute in the list. I encourage you to do more research on for loops. In the future, search on google, look at...
View ArticleAnswer by Hanno Reuvers for How to strip/remove certain characters from a list
The following code achieves your goal. As already suggested by @drum, the replace method is useful for this.lst1 = ['ZINC1_out.pdbqt', 'ZINC2_out.pdbqt', 'ZINC3_out.pdbqt']lst2 = []for i in lst1:...
View ArticleHow to strip/remove certain characters from a list
I am currently trying to remove certain characters recursively from a python list.I have a list:lst1 = ['ZINC1_out.pdbqt', 'ZINC2_out.pdbqt', 'ZINC3_out.pdbqt']I would like to remove the '_out' so that...
View Article
More Pages to Explore .....