Create your own


#1

dictus = {"a" : "acutus", "b" : "baranus", "c" : "Treviranus", "d" : "Ti chto, daun?"}

for key in dictus:
  if key == dictus[key][0]:
    print key+" "+dictus[key]
  else:
    print key+" "+dictus[key]+" !!! The "+dictus[key]+ ' does not stand for "'+key+'"!'
else:
  print "What I'm doing with my life..."

In this code the "c" key ALWAYS comes before "b " key, and I don't know why
Help me please, I want them to come consistently


#2

for key in sorted(dictus.iterkeys()):

#3

The reason is, Dictionary in is not ordered data type .
As It has key to access the values and
it does not have anything like 0-indexing(in case of list/tuple/string)

well you can read more about it.
associative array.

There are some changes in python 3.0
You can look up this link

and rest is mentioned by @megasurfer59675


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.