i'm trying to delete all strings after || in the following list:
mylist=[' # - || CAICEDO','LoL','lora',' moco','Sar || var']
For that, i'm using:
def limp_2(n):
return re.sub(r'^(\w+)-([\||\.])(.+)','',n)
clean_2=list(filter(limp_2,clean_1))
print(clean_2)
The idea is to get:
mylist=[' # - ','LoL','lora',' moco','Sar']
Instead, I just have the same list. That is just an example, I want to apply that to a large list.
I'll appreciate your help.
||in some element of the list are removed ?return n.split("||")[0].strip()if you want to do what you asked - see rextester.com/ZYOHO99856[0].stripand how is related with .split. I haven't found the part in[]as a parameter for .split. Thanks again.