0

Why is index not starting from zero i.e first element always? At times it goes from from 1 to 0; at times it goes from 0 to 1? i want the index to start from zero always. Kindly help me how to fix this.

Queries={'Q1':'question 1','Q2':'question 2'}

for k,val in Queries.items():

   print('key:{} value:{}'.format(k,val))
pavan sunder
  • 99
  • 4
  • 15
  • 1
    There is no index referenced in your code, but you may want to note that [dictionaries are unordered](https://stackoverflow.com/questions/15479928/why-is-the-order-in-dictionaries-and-sets-arbitrary). – Jared Goguen May 24 '17 at 14:17
  • since 2.7 there's a collections.OrderedDict is a dictionary subclass that remembers the order in which its contents are added. – Nahuel Fouilleul May 24 '17 at 14:22

0 Answers0