0

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

4
  • 3
    continue statement? Commented Mar 30, 2014 at 5:44
  • You need to load the two files into memory as well. Since you are new to code, I would suggest that you should post the whole code here. Also, look at the continue statement as @thefourtheye suggested. Commented Mar 30, 2014 at 5:47
  • so something along the lines of token = test_list.skip() continue? Commented Mar 30, 2014 at 5:47
  • 1
    Just get rid of the second if statement. Commented Mar 30, 2014 at 5:50

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.