-1

I was wondering if there is a C++ "map"-like thing in Python. For example if I have 10^9 items and each one needs to hold one value: True or False (only the "True"-values are meaningful, but in order to check fast and not in O(n^2)), my code is very inefficient:

for k in range(0, numberOfItems):
myList.append([False])

I can check the value is True or False, but with larger numbers, like 10^9, I get a runtime error because of the list size. It just can't hold that many items. Any help would be appreciated, thanks in advance!

Kurns
  • 157
  • 10

1 Answers1

-2

Sure that exist you can use dictionary !
See docs for more informations over how it works : link to python documentation over dictionary

  • You should give an example (not shown at first posting this type of question) and not just a referal. Please improve your answer. – ZF007 Jan 01 '18 at 14:34
  • Thanks for providing an answer. To make sure that answers are always helpful and up to date, link-only answers are discouraged. You can improve your answer buy giving some context around the documentation by showing how to use a dictionary yourself, for example. You can learn more about how to give an answer here: https://stackoverflow.com/help/how-to-answer – stefanobaghino Jan 01 '18 at 14:38