0

How do I retrieve the keys from all my users below down here with the get method?

anotherDict = {
      'user1':  [842.86917819535, 25.58264089252],
      'user2':  [706.92644963185, 27.22746146366],
      'user3':  [696.60346488317, 25.67540525994],
}
CARTOS
  • 221
  • 2
  • 8
  • 1
    Possible duplicate of [How to return dictionary keys as a list in Python?](https://stackoverflow.com/questions/16819222/how-to-return-dictionary-keys-as-a-list-in-python) – Cleb Jan 05 '18 at 13:05
  • You can just use `list(anotherDict)`, see the link from above. – Cleb Jan 05 '18 at 13:10
  • The reason I specified the get method is that I want to retrieve it by indexing. Inserting the dict method will conflict on this. But with list method it will yes. – CARTOS Jan 05 '18 at 13:51
  • Then I do not understand what you are trying to achieve :) What do you mean by "retrieve by indexing"? – Cleb Jan 05 '18 at 14:01
  • Indexing by the unique id that that¨s given for all the lists. Like for example list 15: list(anotherDict.keys())[15] – CARTOS Jan 06 '18 at 20:52

1 Answers1

0

Use

anotherDict.keys() 

This gives you a list:

 [ 'user1', 'user2', 'user3' ]

With the get method you can get the 'value' of a single element.

Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119