-10

How to disable the new line behavior of \n in python3.6 strings? For example:

In:  >>> a = input("Please enter a sentence: ")
Out: blah blah \n blah

In:  >>> print(a)
Out: blah blah \n blah
Christian Dean
  • 20,986
  • 7
  • 47
  • 78
J. Lin
  • 1
  • 1
  • do you mean [`str.replace`](https://docs.python.org/3/library/stdtypes.html#str.replace) or what? – Azat Ibrakov May 16 '17 at 05:31
  • What do you mean by "disable"? – user2357112 May 16 '17 at 05:32
  • 1
    Possible duplicate of [Print statements without new lines in python?](http://stackoverflow.com/questions/12124026/print-statements-without-new-lines-in-python) – Stephen Rauch May 16 '17 at 05:32
  • Did you enter the `\n` _manually_? – ForceBru May 16 '17 at 05:33
  • see the answer here http://stackoverflow.com/questions/7173850/possible-to-get-user-input-without-inserting-a-new-line – Tal Avissar May 16 '17 at 05:36
  • What is that example supposed to be? its not the shell, its not a saved program. It doesn't make sense. What you've shown isn't valid python.. I can't figure out whether you've manually typed a `\` and a `n` in response to a prompt. Show us something real and then we can comment on it. – tdelaney May 16 '17 at 05:37
  • @tdelaney - this user appears to be using ipython. – Shadow May 16 '17 at 05:45
  • @shadow - the ipython looking stuff was added by someone other than the author after my question. I'm not sure that's justified. I'd prefer to hear from the original author. – tdelaney May 16 '17 at 06:07
  • Ah, sorry I missed that. In my opinion, that should be reverted. It doesn't add anything of particular value to the question. – Shadow May 16 '17 at 06:09

2 Answers2

1

As per the documentation;

print(a, end="")
Shadow
  • 7,997
  • 4
  • 45
  • 55
-5

a = input("Please enter a sentence: ")
k = list(str(a))
e = ''.join(k)
print(e)

J. Lin
  • 1
  • 1