'Check if partial string in JSON values in Python

I'm trying to check if a value contains a partial string in this sample API call result in JSON format. It should look through job title text to see if it contains the word "Virtual" or "Remote" anywhere in the string. If so, append 1 to new dictionary, and if not, append 0. I keep getting 1's for each value, but not sure why 0's don't show up if it can't find any match. Thanks! Here's the code:

import requests

remote_job_check = {'Remote':[]}

job_lists = {
      "jobs": [
        {
          "country_code": "US",
          "state": "AL",
          "title": "Sr. Customer Solutions Manager - Virtual Opportunities",
        },
        {
          "country_code": "US",
          "state": "CA",
          "title": "Data Engineer",
        },
        {
          "country_code": "US",
          "state": "CA",
          "title": "Data Engineer - Remote",
        },
        {
          "country_code": "US",
          "state": "NV",
          "title": "Remote Software Engineer",
        },
        {
          "country_code": "US",
          "state": "FL",
          "title": "Product Manager",
        }
     ]
}


job_data = requests.get(job_lists).json()['jobs']
                
for details in job_data:
    if 'Virtual' or 'Remote' in details.get('title'): 
        remote_job_check['Remote'].append(1)
    else:
        remote_job_check['Remote'].append(0)


Solution 1:[1]

I was able to figure it out. Thanks for the suggestions though. I learned that my original code only searches for one of the strings. The 'or' operator wasn't even working in this case:

for details in job_data:
    if 'Virtual' or 'Remote' in details.get('title'): # The 'or' operator not working
        remote_job_check['Remote'].append(1)
    else:
        remote_job_check['Remote'].append(0)

Then I tried using just one string and it worked.

for details in job_data:
    if 'Virtual' in details.get('title'): # This works
        remote_job_check['Remote'].append(1)
    else:
        remote_job_check['Remote'].append(0)

So now I figured I need to create some sort of array to iterate through and found the 'any' function. Here's the working code:

remote_job_keywords = ['Virtual', 'Remote']
    if any(keyword in details['title'] for keyword in remote_job_keywords): 
        job_data['Remote'].append(1)
    else:
        job_data['Remote'].append(0)  

UPDATE: Thanks to @shriakhilc for the feedback on my answer. Like he said, the above works but it was easier to fix the or operator like so:

for details in job_data:
    if 'Virtual' in details.get('title') or 'Remote' in details.get('title'): 
        remote_job_check['Remote'].append(1)
    else:
        remote_job_check['Remote'].append(0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1