An algorithm problem in python

domain_name = ["sohu", "sina", "baidu", "lagou", "qichacha", "tianyancha", "qq.com", "163.com", "juzi.com",
                            "36kr", "cyzone", "qixin", "kanzhun", "liepin", "zhihu", "weibo", "apple", "zhaopin",
                            "baike"]
def filter_url(url):
    for domain in domain_name:
        if domain in url:
            return
        
if filter_url("xy2.netease.com/thread"):
    print("xy2.netease.com/thread")
    
domain_nameurl pass  url 
Sep.17,2021

your filter_url returns None , always None
bool (None) = = False
so if can never pass


def filter_url(url):
    for domain in domain_name:
        if domain in url:
            return True

if I understand what you mean correctly:

def filter_url(url):
    for domain in domain_name:
        if domain in url:
            pass
        else:
            print(url)
In the

function, the function ends as soon as return occurs. If return is used, Filter will be terminated once it is judged to be True,.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea81cf-47c6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea81cf-47c6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?