in Technology by
What is break, continue and pass in Python?

1 Answer

0 votes
by
Break The break statement terminates the loop immediately
and the control flows to the statement after the body of the loop.
Continue The continue statement terminates the current iteration of the statement,
skips the rest of the code in the current iteration and the control flows to the next iteration of the loop.
Pass As explained above, pass keyword in Python is generally used to fill-up empty blocks
and is similar to an empty statement represented by a semi-colon in languages such as Java, C++, Javascript etc.

pat = [1, 3, 2, 1, 2, 3, 1, 0, 1, 3]

for p in pat:
    pass
    if (p == 0):
        current = p
        break
    elif (p % 2 == 0):
        continue
    print(p)    # output => 1 3 1 3 1

<strong style="-webkit-font-smoothing:subp

Related questions

0 votes
    What is the difference between break statement and continue statement ? Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    What is the purpose continue statement in python?...
asked Nov 25, 2020 in Technology by JackTerrance
0 votes
    In my first class i parse my xml file like this : class ListActeurs(): fonction_key = "DiagramElements" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    What is the purpose break statement in python?...
asked Nov 25, 2020 in Technology by JackTerrance
0 votes
0 votes
    What is the purpose pass statement in python?...
asked Nov 25, 2020 in Technology by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    How can I continue this rebase allowing unrelated histories with the forced flag introduced in the new release?...
asked Jan 8, 2021 in Technology by JackTerrance
+1 vote
    Which operator is used to continue the definition of macro in the next line in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    If an index is _________________ the metadata and statistics continue to exists (a) Disabling (b) Dropping (c) ... in SQL in portion Indexing and Hashing of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    I got this question regarding web server (such as nginx, Cherokee or Oracle iPlanet) and Java containers ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I am trying to POST a HTML (contained in a file) to a URL using Wget like this: wget -O- ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I'm using the progress bar of WPF and set the value until the max value. But, when reached, the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
...