Iam new and learning Python. Kindly help me understand the below question.
- What is the output of the following python code if we enter “Hello Python” as input?
inputString = input(‘Enter a string: ‘)
print(inputString, sep=’#’, end=’&’)
The answer was mentioned as “Hello Python&”
Please help understand why the keyword “sep” do not work but “end” works.
This is because
sep is the object separator. You have only provided one object to the
print function, which is a single string.
If the code was
inputString1 = input('Enter a string: ')
inputString2 = input('Enter another string: ')
print(inputString1, inputString2, sep='#', end='&')
and you input
Python as the two inputs, then the result would be
See Built-in Functions — Python 3.10.5 documentation
Thank you for your response