Empty while loop in Python

0 votes
For the following syntax in a code :

    while file.readline().startswith("#"):
        continue

Do i need to use "continue"? Or is there any other syntax for the same?
Dec 5, 2018 in Python by ana1504.k
• 7,890 points
1,495 views

1 answer to this question.

0 votes
while file.readline().startswith("#"):
    pass

The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action.
answered Dec 5, 2018 by SDeb
• 13,250 points

Related Questions In Python

0 votes
0 answers

What is the syntax for an empty while loop in python?

What kind of ambiguities are expected for ...READ MORE

Aug 5, 2019 in Python by Waseem
• 4,540 points
161 views
0 votes
2 answers

Do-while loop in Python

A more pythonic way would be this: ``` while ...READ MORE

answered Jul 5 in Python by Composer3
327 views
0 votes
1 answer

Why there is no do while loop in python

There is no do...while loop because there ...READ MORE

answered Aug 6, 2018 in Python by Priyaj
• 57,700 points
1,622 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,481 views
0 votes
0 answers
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,250 points
889 views
0 votes
1 answer

Print C format in Python

For printf- style formatting and special case ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,250 points
94 views