The following code gives the error
d=sortedmachine s[machine]
TypeError: list indices must be integers
What works for the unsorted dictionary does not work for the sorted
dictionary.
Can anyone help?
machinekey = "111111"
machines = {}
machines[machinekey]=[1,0,0,0,0,0,0,0 ,0,0,0,0,0]
machinekey = "222222"
machines[machinekey]=[0,1,0,0,0,0,0,0 ,0,0,0,0,0]
ddd=0
for machine in machines.keys() :
d=machines[machine]
print machine
print d [ddd]
sortedmachines= sorted(machines )
for machine in sortedmachines:
d=sortedmachine s[machine]
print machine
print d [ddd]
d=sortedmachine s[machine]
TypeError: list indices must be integers
What works for the unsorted dictionary does not work for the sorted
dictionary.
Can anyone help?
machinekey = "111111"
machines = {}
machines[machinekey]=[1,0,0,0,0,0,0,0 ,0,0,0,0,0]
machinekey = "222222"
machines[machinekey]=[0,1,0,0,0,0,0,0 ,0,0,0,0,0]
ddd=0
for machine in machines.keys() :
d=machines[machine]
print machine
print d [ddd]
sortedmachines= sorted(machines )
for machine in sortedmachines:
d=sortedmachine s[machine]
print machine
print d [ddd]
Comment