Prevent python from printing newline

Posted by wrongusername on Stack Overflow See other posts from Stack Overflow or by wrongusername
Published on 2010-03-20T19:33:46Z Indexed on 2010/03/20 19:41 UTC
Read the original article Hit count: 430

Filed under:
|
|
|

I have this code in Python

inputted = input("Enter in something: ")
print("Input is {0}, including the return".format(inputted))

that outputs

Enter in something: something
Input is something
, including the newline

I am not sure what is happening; if I use variables that don't depend on user input, I do not get the newline after formatting with the variable. I suspect Python might be taking in the newline as input when I hit return.

How can I make it so that the input does not include any newlines so that I may compare it to other strings/characters? (e.g. something == 'a')

© Stack Overflow or respective owner

Related posts about python

Related posts about newline