# Print without a newline print('Hello', end='') print('World')
HelloWorld
To print without a newline or space in Python, you can use the end parameter of the print() function. This parameter specifies the string that should be used to end the current line, instead of the default newline character.
To print without a space, you can use an empty string as the end parameter, like this:
# Print without a space print('Hello', end='') print('World', end='')
This will produce the following output:
HelloWorld
You can also use the sep parameter of the print() function to specify a different separator between the items to be printed. This parameter specifies the string that should be used to separate the items, instead of the default space character. Here is an example:
# Print without a space print('Hello', 'World', sep='')This will produce the same output as the previous examples.
It is important to note that, in Python 3, the print() function is a function, not a statement, so you need to include the parentheses when calling it. In Python 2, the print statement is used instead of the print() function, and it does not have the end or sep parameters.
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.