The following code gives the error

d=sortedmachines[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=sortedmachines[machine]
          print machine
          print d [ddd]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to