print("Hello, world!", end='')
In Python, a newline character is represented by the string \n. It is used to indicate the end of a line of text. By default, Python will automatically insert a newline character at the end of a string when it is printed.
However, you can prevent this behavior by adding a trailing comma after the string like the above example shows. This will print the string "Hello, world!" without adding a newline character at the end.
You can also use the print() function to explicitly add a newline character by specifying the end parameter as a newline character:
print("Hello, world!", end='\n')
This will print the string "Hello, world!" followed by a newline character.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.
Subscribe to be the first to know when a new Python course is released.