Getting Error: 'not enough values to unpack' when using list comprehension together with conditional statement in Python
问题 The objective is to create a list comprehension that outputs two values. The for loops look like below paper_href_scopus = [] paper_title = [] for litag in all_td.find_all('a', {'class': 'ddmDocTitle'}): paper_href_scopus.append(litag['href']) paper_title.append(litag.text) As suggested by OP, this can be achieved by paper_href_scopus, paper_title = zip(*[(litag['href'], litag.text) for litag in all_td.find_all('a', {'class': 'ddmDocTitle'})]) However, there is an instances where the all_td