I'm a little new to python and I'm trying to fill raw_input with a formatted string yet my output never changes the "\n" character and always returns null. Is there a way to pump fully formatted string/text through an empty variable?
text = ""
stop = "|"
while True:
text_1 = raw_input()
text += "%s" % (text1)
if text_1 != stop:
pass
else:
break
print text
output:
hello world
how are you
|
hello worldhow are you|
need: hello world how are you |
I'm confused at what you mean by "fully formatted text". I'm also confused at what you mean by "returns null".
raw_input
returns the string that was read, which might be an empty string, but should never beNone
. By the way, if you are familiar withNULL
in C-like languages,None
is sort of the equivalent in Python.This piece of code is close to yours and has what I believe is your desired behavior.