Reputation:
I am trying to print out the maximum amount of value(index 4) between 42000,22000,35000 and 18000.
employee={'1001':['Amy',45,'F','LA',42000],
'1002':['Brian',26,'M','MN',22000],
'1003':['Carrie',30,'F','TX',35000],
'1004':['Diana',22,'F','AZ',18000]}
Expectation: 42000
My work:
for employee_id,info in employee:
for i in info:
print(max(info[4]))
And it says ERROR (ValueError: too many values to unpack (expected 2)) Thanks for helping.
Upvotes: 0
Views: 856
Reputation: 380
try this:
maximum = 0
for value in employee.values():
maximum = max(maximum, value[4])
print(maximum)
Upvotes: 0
Reputation: 10624
Try this:
print(max([employee[i][4] for i in employee]))
Output:
42000
Upvotes: 2