Home >Backend Development >Python Tutorial >What does 'end=' mean in python?

What does 'end=' mean in python?

烟雨青岚
烟雨青岚Original
2020-07-01 17:10:1879276browse

In python, "end=" is a parameter in the "print()" function, which will cause the function to turn off the default behavior of "automatically including newlines in the output". By default, print prints a line with a newline at the end. end passes an empty string to indicate that the statement has not ended.

What does 'end=' mean in python?

"end=" as a parameter in print() will cause the function to turn off the default behavior of "automatically include newlines in the output" .

Pass an empty string for end, so that the print function will not add a newline character at the end of the string, but add an empty string. In fact, this is also a grammatical requirement, indicating that this statement It's not over.

Print defaults to printing one line with a newline at the end. end=' ' means no line break at the end, add a space

As shown below: Use a for loop to implement the multiplication table: (Use end=' ') Gradient display prints one line, add a line break at the end

for i in range(1, 10):
    for j in range(1, i + 1):
        print('{}x{}={}\t'.format(j, i, i * j), end='' )
    print('\n')

What does end= mean in python?

Recommended tutorial: "python tutorial"

The above is the detailed content of What does 'end=' mean in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn