How can remove 2.50\n from this array?
line = ['1.60\n2.50\n2.15', '1.80\n2.20\n1.90']
Tried with split, rsplit but I can't remove
I need result to be
line = ['1.60\n2.15', '1.80\n1.90']
Can regex do it?
CodePudding user response:
If the number that you want to remove from the string is not always the same you can use something like:
new_line = []
for entry in line:
lst = entry.split('\n')
lst.pop(1)
entry = "\n".join(lst)
new_line.append(entry)