Doubt in Python print function

I was learning print function in Python on GeeksForGeeks, and I came across this :

Can someone please tell me what they mean?

sep is optiional parameter like what you want as a separation between what you want to print.


would print a+b+c.

By default python has end=’\n’ without specifying, end can be set to any other parameter based on your need same goes for sep which specifies the separation between two variables in one print function.

‘sep’ is optional parameter which stands for separator, it actually defines how the different strings should join together (‘G’, ‘F’, ‘G’ in your case), By default its value is space(’ '), but you can modify it to any character(in your case it has been modified to ‘’). That’s why its output is GFG, but if you don’t use this parameter so it will give G F G as the output.

Now, coming to ‘end’ param, as ‘sep’ it is also an optional param, it defines how the string will end (in your case string is ‘Python’), the default value of it is ‘\n’ which means break line (or next line), but again you can modify it too to any character (in your case it has been modified to ‘@’), that’s why it has been ended with ‘@’ instead of ‘\n’, that’s why output is Python@GeeksforGeeks, if you don’t use this param, then the output will be:

Hope this will help you! Happy coding :grinning:

1 Like