list_a=[[18, 20],[45, 2],[61, 12],[37, 6],[21, 21],[78, 9]]
我得到了这样的清单。如图所示,list_a的元素采用[a,b]的形式。 我该如何遍历a或b?
答案 0 :(得分:1)
这就是您要尝试做的事情
>>> l = [[18, 20],[45, 2],[61, 12],[37, 6],[21, 21],[78, 9]]
>>> category = []
>>> for i in l:
if i[0]>=55 and i[1]>7:
category.append('Senior')
else:
category.append("Open")
>>> category
['Open', 'Open', 'Senior', 'Open', 'Open', 'Senior']