What is the most efficient way to delete a line from a string in python? I have tried
content = "first line \nsecond line\nthird line\netc.".splitlines()
i = 0
for line in iter(content):
if len(line) < 5:
content[i] = ""
i += 1
content = '\n'.join(content)
where my delete condition is just that the length of the line is smaller than 5 characters. Is there a more elegant/efficient way?