A way to exclude a combination of a pair of a number and a symbol (python)

Solution 1:

You can do this with the RE module:

import re

instructions = re.sub('[1-7]\n|\r|\n', '', instructions)