The input
statement takes the input that the user typed literally. The \
-escaping convention is something that happens in Python string literals: it is not a universal convention that applies to data stored in variables. If it were, then you could never store in a string variable the two characters \
followed by n
because they would be interpreted as ASCII 13.
You can do what you want this way:
import ast
import shlex
a=input("Input: ")
print(ast.literal_eval(shlex.quote(a)))
If in response to the Input:
prompt you type one\ntwo
, then this code will print
one
two
This works by turning the contents of a
which is one\ntwo
back into a quoted string that looks like "one\ntwo"
and then evaluating it as if it were a string literal. That brings the \
-escaping convention back into play.
But it is very roundabout. Are you sure you want users of your program feeding it control characters?