I have a user that can enter in text that a program will print after parsing. That is, the user can enter in something like:
"Print me\nAnd on a newline now"
And it should print as:
Print me
And on a newline now
The string I have now looks like OK\n
when I print it and OK\\n
when I do repr()
on it. I'm having some difficulty converting this to properly print the newline. The only thing that seems to work now is to manually go through each possible entry and do something like:
val = val.replace('\\n', '\n'))
# or, what if they wanted a beep?
# similar to print('\a')
Is there a better way to do this?