1. Trang chủ
  2. » Giáo án - Bài giảng

040 continue statements tủ tài liệu training

2 21 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Python break, continue and pass statements Let's continue with the continue statement continue statement The continue statement is used to skip the rest of the code inside a loop for the current iteration only When the cursor encounters with a continue statement in the loop, the loop does not terminate, in this time, the loop continues on with the next iteration Here is the syntax of continue statement: continue Let’s look at an example that uses the continue statement in a for loop The use of 'continue' statements with "for" loops In [1]: my_list = list(range(11)) for i in my_list: if (i==4 or i==7): continue print("The value of i:",i) The The The The The The The The The value value value value value value value value value of of of of of of of of of i: i: i: i: i: i: i: i: i: 10 The Complete Python Programming Course: (Beginner to Advanced) The use of 'continue' statements with "while" loops Don't run this code! It might have some problems on Jupyter In [2]: #False Usage a = while (a continue print(a) a+=1 KeyboardInterrupt: In [3]: #True Usage a = while (a

Ngày đăng: 17/11/2019, 07:33

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN