for i in node_list]get_hot_posts()以这种方式返回包含3个项目的列表return recent_posts[0:amount-1][temp.append(i.get_hot_post(3)) for i innode_list]
在这个命令之后,在"temp“中,我有一个列表列表,这是很好的。
我正在尝试执行列表理解。我想用较大列表的值检查较小列表中的值。我觉得我的代码行得通。直到我的一个内部列表为空。['w', 'c']IndexError: list index out of range
然而,我想知道的是,什么是正确的方式来编写这个s/t它不会在这里出错,而只是假设没有匹配,并转移到list_one中的下一个列表