I,p=multidict ({1:9, 2:4, 3:7, 4:3})
W,w = multidict ({1:3, 2:5, 3:4, 4:1})
I'd like to create a program that compares the two values of and outputs those that meet the requirements.
for in I:
if p.values(i)<w.values(i)US>:
print(i)
If so,
TypeError: values() takes no arguments (1given)
I don't know because it says
Where should I change it?
from gurobipy import multidict
I,p = multidict ({1:9, 2:4, 3:7, 4:3})
W,w = multidict ({1:3, 2:5, 3:4, 4:1})
for in I:
if i in w and p[i]<w[i]:
print(i)
#
2
Or
from gurobipy import multidict
I,p = multidict ({1:9, 2:4, 3:7, 4:3})
W,w = multidict ({1:3, 2:5, 3:4, 4:1})
keys=[i for i in p if i in w[i]<w[i]]
print(keys)
#
[2]
© 2024 OneMinuteCode. All rights reserved.