carebear
carebear

Reputation: 771

Skipping an element of a list - Python

I have two json files that I open with Python. I want to do something such that if one condition isn't satisfied I can skip the current element and move on to the next one. My code looks something like the following:

t_a = first json file
t = second json file
for token in t_a
    if token in t
     #do something
    if token not in t
     #skip the current token and move on to the next one

My problem comes in with the last step. I'm new to python and I'm not sure how to skip the current element

Upvotes: 0

Views: 1260

Answers (1)

aIKid
aIKid

Reputation: 28342

Just use continue:

t_a = first json file
t = second json file
for token in t_a
    if token in t:
     #do something
    else:
     #skip the current token and move on to the next one
        continue
    #do something else here

Upvotes: 3

Related Questions