How does python accesses the entries of a dictionary when using a for loop? I think that theoretically it is random but when I tried it using integers as keys I saw that it was accessing the dictionary in ascending order of the keys.
For example I tried:
x = {
1: 5,
3: 2,
2: 15
}
for n in x:
print n
and I got:
1,2,3
as an output.
I got the same answer when I used letters as the key values
x = {
d: 5,
o: 2,
c: 15
}
for n in x:
print n
and I got:
c,d,o
Is that always the case??