Reputation: 565
I am looping through a range but every time the i
in range is equal to one of the integers in check_list
, I should continue
and iterate next. Here's my code:
check_list = [23,5,6,3,6,3]
for i in range(1000):
if i == one of the numbers in check_list:
continue
# do something here
Upvotes: 0
Views: 70
Reputation: 19806
You need just to use:
if i in check_list:
Take a look at this example:
>>> check_list = [23, 5, 6, 3, 6, 3]
>>> for i in range(10):
... if i in check_list:
... print(i)
...
3
5
6
Upvotes: 2
Reputation: 12130
Use operator in
:
check_list = [23,5,6,3,6,3]
for i in range(1000):
if i in check_list:
continue
# do something here
Upvotes: 3