Multi-line comments and Python identation error

Asked

Viewed 675 times

1

I was writing my code and I needed to block some lines of code. As there are several, I decided to use the 3 quotes to block a part of the code. inserir a descrição da imagem aqui

However, when I run the code it presents an indentation error. Someone knows what I have done wrong?

inserir a descrição da imagem aqui

I’ve noticed that when I put # This indentation error doesn’t happen.

  • the top of the def open window2 this indented, here comes the string not indented, and then an indented function, will give error even, you must put the indented quotation too

  • What would be quotation??

  • is where the text is a string

1 answer

0


In Python the only thing made to comment code is the # , what are you doing using ''' is just a literal string, meaning a docstring, the same serves to comment, but it must also be alive, as in the example:

def funcao():

    '''
    comentários aqui
    '''
    print("vai printar")

Remember that this is for other things too, for example if you go into an IDE and type help(funcao), what would be shown:

'comentários aqui'

I practically translated that reply for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.