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,870 points
183 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,160 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 in Python by Waseem
• 4,480 points
11 views
0 votes
1 answer

Do-while loop in Python

Python does not have a do-while construct.  If ...READ MORE

answered May 11, 2018 in Python by Hamartia's Mask
• 1,580 points
109 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
• 56,520 points
114 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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 215 views
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,160 points
228 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,160 points
34 views