3 回答

TA贡献1111条经验 获得超0个赞
也许这会奏效:
wage=[]
for var in range(len(brands)):
wage.append(brands[var][1])
min=wage.index(min(wage))
print("The lowest wage :{0}, {1}".format(brands[min][0],brands[min][1])

TA贡献1816条经验 获得超4个赞
您可以按所需的类别使用lambda进行排序,将参考工资,然后打印相应的指数,即我们的低点和高点 key=lambda x: x[1]list[0][0], list[0][x]list[-1][0], list[-1][x]
wage = sorted(brands, key=lambda x: x[1])
print('The lowest wage: {}, {}'.format(wage[0][0], wage[0][1]))
print('The highest wage: {}, {}'.format(wage[-1][0], wage[-1][1]))
hours = (sorted(brands, key=lambda x: x[2]))
print('The lowest working hours: {}, {}'.format(hours[0][0], hours[0][2]))
print('The highest working hours: {}, {}'.format(hours[-1][0], hours[-1][2]))
The lowest wage: Google, 110
The highest wage: Apple, 150
The lowest working hours: Google, 35
The highest working hours: Apple, 40
添加回答
举报