I am trying to print a line by taking the user input. But there is an empty space before the user input is printed:
Code:
UserInput = input('Enter a string: ')
print("\nEntered string is:\n", UserInput)
Output:
Enter a string: I need this, but not this
Entered string is:
I need this, but not this
Ideally the output should have been: Enter a string: I need this, but not this
Entered string is:
I need this, but not this
Please can someone let me know??
The comma is causing an extra space before the user input string. Replace the comma in the print statement with +
sign.
UserInput = input('Enter a string: ')
print("\nEntered string is:\n" + UserInput)
Output:
Enter a string: I need this, but not this
Entered string is:
I need this, but not this