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

前端 未结 11 1398
孤街浪徒
孤街浪徒 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:01

    continue will jump back to the top of the loop. pass will continue processing.

    if pass is at the end for the loop, the difference is negligible as the flow would just back to the top of the loop anyway.

提交回复
热议问题