0

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 !

Norbert Bartko
  • 2,468
  • 1
  • 17
  • 36
  • Possible duplicate of [What are the difference between sep and end in print function?](https://stackoverflow.com/questions/36513028/what-are-the-difference-between-sep-and-end-in-print-function) – Michele Bastione Oct 01 '19 at 16:02
  • You should learn more about the print function: [check it out.](https://stackoverflow.com/questions/36513028/what-are-the-difference-between-sep-and-end-in-print-function) – Michele Bastione Oct 01 '19 at 16:05

3 Answers3

1

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!
Óscar López
  • 232,561
  • 37
  • 312
  • 386
1

Comma , by default leaves a space after a string. You can try using +:

print("Hello, " + a + "!") =>Hello, Ste!

Bob
  • 236
  • 1
  • 4
0

Use the strip function to cut the space at the initial and end of the string.

print("Hello,", a.strip(), "!", sep="")
Rajeshkumar
  • 59
  • 1
  • 1
  • 9