with open('practice.txt','w') as x:
text = input('enter text')
x.write(text)
enter text .. hello\n world
output .. hello\n world
it takes it as a string not as a newline character why is my input string when passed to a write() not validating my'\n' character
Does it have something to do with me passing input() to write()
\nis only used to represent a newline. Those two characters don't have any special meaning here becauseinput()doesn't parse escape sequences. You'll have to figure out a way to do that yourself (e.g.text = text.replace('\\n', '\n')).