Reputation: 1
Why does it remain a space between Ste and !? How can I eliminate it, without using a difficult function?
a = input("Enter a name: ")
Enter a name: Ale
print("Hello,", a, "!")
Hello, Ste !
Upvotes: 0
Views: 181
Reputation: 236
Comma ,
by default leaves a space after a string. You can try using +
:
print("Hello, " + a + "!")
=>Hello, Ste!
Upvotes: 1
Reputation: 59
Use the strip function to cut the space at the initial and end of the string.
print("Hello,", a.strip(), "!", sep="")
Upvotes: 0
Reputation: 235994
By default, print
separates each of its arguments with a space. You can change it by specifying the sep
parameter with something else, including an empty string. This should work:
print("Hello, ", a, "!", sep="")
=> Hello, Ale!
Upvotes: 1