0

When I print and input, it always shows \n, is there a way to avoid it?

print ("What is your name?“ name = sys.stdin.readline() print ("Hello", name.capitalize) It shows me ('Hello', 'Paul\n') Is there no way it can print it without the " \n ", " ' " and " , " ?

20th Sep 2016, 6:17 PM
Paul Osakue
Paul Osakue - avatar
3 Respuestas
+ 2
use raw_input () instead of sys.stdin.readline () as sys.stdin.readline () does not strips the newline character '\n'
20th Sep 2016, 7:13 PM
Yogendra Bist
Yogendra Bist - avatar
+ 2
for details you can read 'Rationale' section on http://www.python.org/dev/peps/pep-3111/
20th Sep 2016, 7:19 PM
Yogendra Bist
Yogendra Bist - avatar
+ 1
Okay thanks
20th Sep 2016, 7:17 PM
Paul Osakue
Paul Osakue - avatar