Oct-01-2020, 02:27 AM
Usually you'll want to
rstrip()
, which by default removes any whitespace from the right end.result = [line.rstrip() for line in testfile if "2" in line]