Is there a difference between `continue` and `pass` in a for loop in python?

前端 未结 11 1395
孤街浪徒
孤街浪徒 2020-11-27 09:05

Is there any significant difference between the two python keywords continue and pass like in the examples

for element in some_list         


        
11条回答
  •  忘掉有多难
    2020-11-27 10:02

    Yes, there is a difference. Continue actually skips the rest of the current iteration of the loop (returning to the beginning). Pass is a blank statement that does nothing.

    See the python docs

提交回复
热议问题