I'm defining a function that concatenates two strings given by the user, but the string returned by sys.stdin.readline() includes the newline character so my output doesn't look concatenated at all (technically, this output is still concatenated, but with a "\n" between the two strings.) How do I get rid of the newline?
def concatString(string1, string2):
return (string1 + string2)
str_1 = sys.stdin.readline()
str_2 = sys.stdin.readline()
print( "%s" % concatString(str_1, str_2))
console:
hello
world
hello
world
I tried read(n) that takes in n number of characters, but it still appends the "\n"
str_1 = sys.stdin.read(5) '''accepts "hello" '''
str_2 = sys.stdin.read(3) '''accepts "\n" and "wo", discards "rld" '''
console:
hello
world
hello
wo