Recursive function gives no output
Question: I'm scrapping all the URL of my domain with recursive function. But it outputs
nothing, without any error.

    
    
    #usr/bin/python
    
    from bs4 import BeautifulSoup
    import requests
    import tldextract
    
    
    def scrap(url):
    
        for links in url:
            main_domain = tldextract.extract(links)
            r = requests.get(links)
            data = r.text
            soup = BeautifulSoup(data)
    
            for href in soup.find_all('a'):
                href = href.get('href')
                if not href:
                    continue
                link_domain = tldextract.extract(href)
    
                if link_domain.domain == main_domain.domain :
                    problem.append(href)
    
                elif not href == '#' and link_domain.tld == '':
                    new = 'http://www.'+ main_domain.domain + '.' + main_domain.tld + '/' + href
                    problem.append(new)
    
            return len(problem)
            return scrap(problem)
    
    
    problem = ["http://xyzdomain.com"]  
    print(scrap(problem))
    

When I create a new list, it works, but I don't want to make a list every time
for every loop.


Answer: You need to structure your code so that it meets the pattern for recursion as
your current code doesn't - you also should not call variables the same name
as libraries, e.g. `href = href.get()` because this will usually stop the
library working as it becomes the variable, your code as it currently is will
only ever return the len() as this return is unconditionally reached before:
`return scrap(problem)`.:

    
    
    def Recursive(Factorable_problem)
        if Factorable_problem is Simplest_Case:
            return AnswerToSimplestCase
        else:
            return Rule_For_Generating_From_Simpler_Case(Recursive(Simpler_Case))
    

for example:

    
    
    def Factorial(n):
        """ Recursively Generate Factorials """
        if n < 2:
            return 1
        else:
            return n * Factorial(n-1)
    

