[Python] Is there any importance for indentation when breaking a line (using backslash or...

Discussão em 'Python' iniciado por Stack, Fevereiro 13, 2025.

  1. Stack

    Stack Membro Participativo

    Is there any importance for indentation when breaking a line (using backslash or parentheses) in python? How about the style recommendation, which one is recommended?

    For example this code block:

    def print_empty_square(size, c):
    for row in range(size):
    for col in range(size):
    if (row == 0 or row == size -1
    or col == 0 or col == size -1):
    print(c,end = "")
    else:
    print(' ',end = "")
    print()


    def print_empty_square(size, c):
    for row in range(size):
    for col in range(size):
    if (row == 0 or row == size -1
    or col == 0 or col == size -1):
    print(c,end = "")
    else:
    print(' ',end = "")
    print()


    I tried both codes, they both run successfully.

    Continue reading...

Compartilhe esta Página