0

hi i have a function which returns a list and a dictionary. if functions renturns one thing i know how to use that. but how i can use returned list and dict of function?

my code is :

def links(url):
    __url = str(url)  # find_dl_url()
    __page = requests.get(__url)
    __page_content = bs4.BeautifulSoup(__page.content)
    __links = __page_content.select('a[href*=".mkv"]')
    __dict = {}
    __sorted_dict = {}
    __list = []
    for links in __links:
        __dict[links.string] = links.get('href')
        __list.append(links.string)
    __list = sorted(__list)
    print(__list)
    print(__dict)
    return  __list, __dict

if function returnes just one list i could write:

list=links(url)

but how i can get both of list and dictionary?

1 Answer 1

3

You can unpack the returned variables

lst, dct = links(url)
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.