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?

Bahrom
  • 4,752
  • 32
  • 41
Saeb Molaee
  • 109
  • 15

1 Answers1

3

You can unpack the returned variables

lst, dct = links(url)
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218