python - how to iterate from index n to m of an OrderedDict? -


this question has answer here:

i have ordereddict , iterate on subset of elements, index n m.i can simple way:

from collections import ordereddict  d = ordereddict() in range(10):     d[i] =  n = 3 m = 6 c = 0 in d:     if n <= c <= m:         print(d[i])     c += 1 

but looking more compact, similar slicing lists:

n = 3 m = 6 l = [i in range(10)] in l[n:m+1]:     print(i) 

is there such mechanism ordereddict?

it depends on how ordereddict created (n , m need consider index of items in d), how this:

d.values()[n:m] 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -