Most voted "dictionary" questions
A dictionary in computer science is a data structure that maps keys to such values that given a key of their corresponding value can be efficiently retrieved. Use this tag for this data structure and not for [dictionary-of-data] normally used with database or for [algorithms-to-dictionary] to manipulate traditional word dictionary
Learn more…184 questions
Sort by count of
- 
		18 votes3 answers1094 viewsAssign value to a dictionary variable that is optionalI have a function where one of the parameters is a dictionary, but it’s optional. I need to assign a value in this dictionary, but take into account the case where this parameter is not filled in.… 
- 
		17 votes2 answers764 viewsWhat is the difference between a map, a dictionary, an associative array and a hash table?These terms refer to structures that have very similar, if not equal, characteristics. They often seem to be used interchangeably. This would just be different nomenclature depending on the… 
- 
		10 votes1 answer318 viewsIs there any pythonic way to make "Slice" from an array?In Javascript there is the Array.prototype.slice: var input = [ 'laranja', 'limão', 'melancia', 'mamão' ]; var aparada = input.slice(1, -1); console.log( aparada ); And in the PHP the array_slice:… 
- 
		8 votes2 answers385 viewsIn which scenario is it recommended to use Keyedcollection instead of a Dictionary?I didn’t know about the existence of KeyedCollection until you see this reply gypsy. I wondered how and when to use a KeyedCollection, since there is the Dictionary which apparently has the same… 
- 
		8 votes3 answers953 viewsHow do you relate the hash which is also called the python dictionary to the encryption hash function?I would like to understand how the encryption 'hash' function (in which passwords for example are encrypted) relates, with the key-value hash in programming (also known as 'dictionary' in Python for… 
- 
		7 votes2 answers4107 viewsDictionary SearchI have the following Dictionary: public static Dictionary<string, string> ObterCodigo() { return new Dictionary<string, string> { {"18", "Teste"}, {"19", "Teste"}, {"02", "AAA"}, {"03",… 
- 
		7 votes1 answer922 viewsRedeem dictionary key with maximum sum of respective valueI have the following dictionary: dic = {'bsx_8612': [23, 567, 632], 'asd_6375': [654, 12, 962], 'asd_2498': [56, 12, 574], 'bsx_9344': [96, 1022, 324]} I want to redeem the key whose value has the… 
- 
		7 votes2 answers161 viewsHelp Using List Comprehension/DictionaryHello, I have the following module (did not want to put all the code here) in Python >= 3.6. It is already functional in the current state, although it does not handle all possible errors. But I… 
- 
		7 votes2 answers87 viewsWhat is the relationship between unhashable and mutable?I always use strings as keys in dictionaries, but, studying the theme, I noticed that it is possible to use any immutable object. So, in addition to strings, dictionaries accept as keys objects such… 
- 
		6 votes1 answer200 viewsIs a Python dictionary as efficient as a tree or a hash?I use a lot of Python dictionaries: dic = dict() #ou dic = {} dic['113654'] = {'nome': 'João', 'idade': 21} dic['853872'] = {'nome': 'Maria', 'idade': 27} dic['427845'] = {'nome': 'Fernando',… 
- 
		5 votes1 answer4479 viewsPortuguese dictionary online for performing requestsI am looking for an online dictionary in Portuguese that allows me to do requests as the example: http://www.exemplo-dicionario.com/dicionario?palavra=palavra-pretendida And answer the definition of… 
- 
		5 votes3 answers392 viewsWhy in Python can we define an index of a Dict as a Tuple?I noticed that in Python, we can add values like tuple as an index of a dict (dictionary). Example: test = {} test[(1, 2, 3)] = ("um", "dois", "tres") print test // {(1, 2, 3): ('um', 'dois',… 
- 
		5 votes2 answers14521 viewsSort dictionary by Python valueI have a dictionary with the following format dic={759147': 54, '186398060': 8, '199846203': 42, '191725321': 10, '158947719': 4} would like to know if there is how to sort it by value and print on… 
- 
		5 votes1 answer132 viewsDifferent types of python dictionariesIs there any way to convert this dictionary: d = {'Ano; Dia; Mes' : '1995; 2; 5'} for this format: d = {'Ano': '1995'; 'Dia' : '2'; 'Mes': '5'} Thank you… 
- 
		5 votes3 answers2721 viewsHow to join several Python dictionaries?In some languages, it is possible to unite objetos/array in one. For example, in PHP, I can join several arrays thus: $userInfo = ['name' => 'Wallace'] $jobInfo = ['job' => 'Developer']… 
- 
		5 votes2 answers367 viewsHow to optimize my access to the Python dictionary?I have a dictionary of the form sequinte: dicionario = {'1':'Banana','7':'Maçã','3':'Pera','2':'Melancia'} If I check the key '2' in the dictionary: if '2' in dicionario:. My programmer intuition… 
- 
		5 votes1 answer78 viewsA method can access the properties of the object it belongs to when stored through a delegate?I’m building a dictionary of the following kind: <string, delegate>, that will access a method belonging to an object of the following class: class Example{ public int Power { get; set; }… 
- 
		5 votes2 answers50 viewsHow to relate a column to a dictionary in R?library(tidyverse) I have a dataset that has in one column titles of articles and in another column, their respective authors. I reproduce here a row of this dataset: df<-tibble( titulo= "A… 
- 
		4 votes2 answers6881 viewsGraph possible python pathsI have a dictionary, where the key is a vertex and the value is a list of vertices adjacent to the vertex (key). dic = {'A':['B,'C'],'B':['A','C','D'],'C':['A','B','D'],'D':['B','C']} What I want is… 
- 
		4 votes1 answer1794 viewsHow can I check if an object exists in the dictionary and return itI am working on a solution in which I must enter on the same function with a given name of a Park. The parks are implemented in a list and each park has a name. It happens that I intend and already… 
- 
		4 votes1 answer1542 viewsJava Dictionary APIHi, I’m looking for a dictionary API in Java to create the program in the following steps: User enters with a string, in this case a word; I print on the screen the invocation of a method of this… 
- 
		4 votes1 answer94 viewsFile installation/copy systemHow to use items SortedDictionary File.WriteAllBytes to start or complete a file and folder installation process for the computer. Ex: File list: void AlocarArquivos(){ var arquivo_e_pasta = new… 
- 
		4 votes3 answers655 viewsHow to use a dictionary value to call a specific Python function?I’m trying to use a dictionary to identify each function to a value, and call them over the program. My code is below (example): #!/usr/bin/env python menuOpt = { 1 : "valor", } #Main if __name__ ==… 
- 
		4 votes3 answers2680 viewsHow to iterate over a dictionary?I have seen several ways to iterate over a dictionary. There is one considered standard? 
- 
		4 votes1 answer1099 viewsHash, Object or Dictionary?I have been studying python and ruby and have seen that several other languages as well as these two make use of different terminologies to determine a ' Json object. var objeto = { 'name' : 'Darth… 
- 
		4 votes1 answer129 viewsDoubt how to display the name of a dictionary keyIt is possible to display the name of only one key of a dictionary? ex: notas_por_materias = { "Matematica" : 7, "Portugues" : 8, "Historia" : 10 } I can display a print showing the subject name and… 
- 
		4 votes1 answer115 viewsCreating a dictionary with void functionsI am for fun to develop a TCP server in C# that performs functions depending on the message that the connected client sends you, for now, I only managed to do what I want with functions that return… 
- 
		4 votes1 answer161 viewsOutput composite structures in Python in Google ColabI have this list called "brazil" and I wanted to understand why when I asked for it in Google Colab Notebook calling its respective variable, the list is presented in a certain order and when I… 
- 
		3 votes4 answers3125 viewsDealing with collisions in Dictionary C#I need to map a string array to a dictionary so that I can later test whether an informed string is valid by checking if it is part of the dict, additionally would like to recover some other… 
- 
		3 votes1 answer257 viewsCreation of Graph in Dictionary form returning integersI am implementing a Python code for Graph creation with open (filename, "r") as f: d = {} for line in f: key, value = line.split() if key not in d: d[key] = [value] else: d[key].append(value)… 
- 
		3 votes1 answer736 viewsYou can access the key through the value:In dictionaries, in Python, is it possible to access a key through the value? Is there any method that inverts key/value? 
- 
		3 votes2 answers856 viewsSort lists in python dictionariesHello, I’m trying to sort my dictionary, but I’m finding it difficult. dict = {'EstacaoCodigo' : ['1','2','3'] ,'NivelConsistencia' : ['0','2','1'] ,'Data' : ['01/12/1996','01/12/1999','01/12/1994']… 
- 
		3 votes1 answer258 viewsHow to improve the performance of a key search?In view of the fact that TDictionary exposes only ways to recover value through the key, I have the following algorithm to fetch a key from its value: var Table: TDictionary<Int64, Extended>;… 
- 
		3 votes1 answer595 viewscheck if two keys in a dictionary have equal valueshello, I have a dictionary {'A': ['B', 'C'], 'B': ['A', 'C'], 'C': ['A', 'B']}, I would like to know if there is any way to check if for example the key 'A' and the key 'C' have equal elements and… 
- 
		3 votes1 answer431 viewsHow to import XML from Data Dictionary to SQL Server?To put it in context, I’m making a data dictionary for a local database, so I used a tool called "Database Notetaker". This tool loads the database data and allows me to comment on the table data… 
- 
		3 votes3 answers1087 viewsFunction to return letter frequencies in an arrayI was trying to do the function that is in the title, but I did not succeed, looking at the solution code for such function, I could not understand, follow the code: function letter_frequency(s) {… 
- 
		3 votes1 answer59 viewsCreate a key/value association from user-informed data8) Write an algorithm capable of receiving a variable amount of parameters that are associated with a key. Then print on the screen the name of the key and its value: def… 
- 
		3 votes3 answers351 viewsHow to access the key, by value, in python dictionary?When filling in the name of 10 people and their respective heights, I need to show on the screen the name of the tallest person. However, I can only get the highest value. Could someone help me?… 
- 
		3 votes3 answers220 viewsHow to popular a dynamically key and value dictionary?Write a program that takes an integer n value and returns a dictionary where the keys are numbers from 1 to n and the values are the squares of their respective keys. Ex: for n = 8, the result… 
- 
		3 votes2 answers536 viewsAdd values between ICTGOAL: I am trying to add the values between Dict ct_db and ct_db2, whenever the keys are equal. Example: RR-00 == RR-00, so make 14 + 223 Problem: It is not being compared all Dict keys, the… 
- 
		3 votes1 answer98 viewsWhy when ordering a list with Sort(), returns None?The following script sorts a dictionary: d = {'a': 10, 'g': 15, 'c': 67, 'z': 90, 'e': 144} ordenada = list(d.keys()) # gera uma lista das chaves do dicionário (protegida por uma tupla)… 
- 
		3 votes3 answers105 viewsFind and change specific Python dictionaryI have to perform a search inside a list with dictionaries inside, looking for the person’s specific CPF, to confirm their data, and thus change some specific dictionary item. My list is:… 
- 
		3 votes2 answers55 viewsHow to save a dictionary to two independent objects in Python?Consider the following dictionaries: dic1 = {'k1':'Ford','k2':'GM','k3':'Dodge'} dic2 = {'k4':'Audi','k5':'Mercedes','k6':'VW'} dic3 = {'k7':'Fiat','k8':'Mazda'} The goal is to get two new… 
- 
		2 votes1 answer549 viewsCalling dictionary in another View Controller SwiftI am trying to pass a dictionary from one Viewcontroller to another, I have succeeded, but the dictionary I am passing through is empty. I want to pass the dictionary after adding the userinput when… 
- 
		2 votes2 answers180 viewsHow to delete Tableviewcell as a Swift DictionaryI’m trying to rule out a TableViewCell using Swipe to delete style, but I cannot delete Cells. Cells are being created by a dictionary that creates each with the key as title and value as details.… 
- 
		2 votes0 answers47 viewsAre there large differences in the "binary recording" of a file, when entering lists or dictionaries?I’m developing a language project C# where I need to use files to store the data circulating in the data structures. Turns out I had the whole project all worked out, I wasn’t layering. I was… 
- 
		2 votes4 answers16229 viewsHow to add entries to a dictionary?How to add user-provided entries to a dictionary? For example: Entree: 1 abcde 2 adecd 3 aaabb The created dictionary would be: dicionario = {'abcde' : 1, 'adecd' : 2, 'aaabb' : 3} or dicionario =… 
- 
		2 votes1 answer4199 viewsHow to stop a loop using the input provided by the user?I’m writing a program that receives entries and creates a dictionary from them. I need the loop I use to insert the entries in the dictionary to be broken when the entry is "9999", but it is not… 
- 
		2 votes1 answer142 viewsAccessing variables dynamically in C languageI understand that it is possible to access variables dynamically in Javasscript, but to do this in C, I can’t find anywhere. Follow the code in Javascript: var n1,n2,n3,n4,n5; n1 = n2 = n3 = n4 = n5… 
- 
		2 votes1 answer1263 viewsCreate python dictionaries using listsI’m trying to create a translator that translates Portuguese words into binary code. I was able to do this to type only one word, but when I try to use 2 words, in the case "ab", nothing happens. I…