Doubt of command in Python

-2

I'm migrating from batch programming to Python, in batch there was the "goto" command, which basically created a sub-area within the command:

goto EXEMPLO
pause

:EXEMPLO
pause

So, when the command arrives in "EXAMPLE" it jumps to the line "EXAMPLE", is it possible to do this in Python? (Use o 3.6)

    
asked by anonymous 12.12.2017 / 19:14

1 answer

1

No. In Python you should use repetition structures and conditional structures to control the flow of your code.

To execute lines of code if a drive is true, you do the following:

minhaVariavel = 5

if minhaVariavel == 5:
    print('O valor eh 5')
else:
    print('O valor nao eh 5')

To repeatedly execute a snippet of code while a condition is true, you do the following:

minhaVariavel = 0

while minhaVariavel < 5:
    print('O valor eh ' + str(minhaVariavel))
    minhaVariavel += 1

And there are many other control structures.

The official language site has a tutorial on this, you can access here: link

Do not forget to indent your code!

    
12.12.2017 / 19:21