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
-
2
votes1
answer124
viewsDictionary<string, string> or Namevaluecollection?
What’s the difference in using Dictionary<string, string> and NameValueCollection? I researched, but only found in English in the same Sopt, I used the translator, but the translation became…
-
2
votes1
answer529
viewsHow to add a new dictionary inside another dictionary?
ini={"MAIN":{}} ini['MAIN']['Nome']="Jaque" print ini Print output: {'MAIN': {'Nome': 'Jaque'}} How to put a new dictionary into what already exists? I want to have it: {'MAIN': {'Nome': 'Jaque'}…
-
2
votes3
answers356
viewsinsert into the dictionary
I have a dictionary in javascript: var dict = {} And I need to insert a value inside it. I tried to use dict.add("chave":"valor"); but it didn’t work. How can I add a new key/value inside the…
-
2
votes1
answer192
viewsSort dictionary and add python values
I have this text file that is processed to capitalize and this part does correctly. olá meu nome é meu nome pois eu olá é meu nome walt não disney olá Then I have this function which should be able…
-
2
votes2
answers684
viewsTransform object to Dict in python
Good team, blz ? So, I started to study python now and wanted a help from you on the following question: I need a class that receives two distinct arrays (words and key) and relates all elements of…
-
2
votes1
answer480
viewsDifference between Dictionaries and Lists/Arrays?
I am trying to understand the concept of each and its differences. I want to understand in which situations to use one or the other.
-
2
votes2
answers98
viewsHow to pass a Dict within a function, to be used in any case if necessary?
Good afternoon, I have a big keyError problem, because in my program that makes use of Dict will perform several processes, and if at some point he does not find an item in which he looks, will…
-
2
votes2
answers110
viewsCompare dictionary key with an integer
My teacher gave a problem to be solved by the class. Given a sentence, we want to know which letter appears the most, always working with lowercase letter, that is, disregarding the distinction…
-
2
votes0
answers144
viewsI need to fix my Python Graph class to simulate a dictionary
Hello, I am trying to fix my graph class to use as a dictionary further forward, but from what I understand it is only accessing the memory location instead of the data, in the example below I will…
-
2
votes1
answer76
viewsCorrect use of lambda with filter()
Here is a practical example of a script that simulates a seller’s sales days and extracts only the days when the seller hit the day’s quota. The list represents the month (I entered only 3 days for…
-
2
votes4
answers350
viewsHow to add values from a dictionary with arrays by the Python key?
I have the following dictionary: { 'tvmv': [121, 250, 48, 45, 54, 120, 115, 138, 60, 30, 274], 'avic': [358, 60, 40], 'hotels_resorts': [60, 31, 45, 50, 300, 165, 40, 46], 'avani': [70, 40],…
-
1
votes1
answer81
viewsAn IPA dictionary of American English?
I want to refer to a text file in the format: A=[ə] A(1)=['eɪ] A’S=['eɪz] A.=['eɪ] A.’S=['eɪz] A.S=['eɪz] A42128=['eɪf'ɔrt'uw'ʌnt'u'eɪt] AAA=[trːɪpəɫ'eɪ] AABERG=['ɑbɝg] AACHEN=['ɑkən]…
dictionaryasked 9 years, 5 months ago Antônio 11 -
1
votes1
answer886
viewsCreate a list of python Dict
I have the following python function def playersID(self, listDetals): listPlayersID = [] tempDict = {} for x in listDetals: for y in x['result']['players']: tempDict.clear() tempDict['match_id'] =…
-
1
votes1
answer398
viewspython request iugu returns status 400
I’m testing the api of yugu. to generate boletus payments and I’m having problems returning json because there is no error in Dictionary items that is sent to the API (in php it would be an array)…
-
1
votes1
answer1156
viewsRead txt with numbers and create a Python dictionary
Good afternoon I’m trying to create a Graph from a Txt file but in the generated dictionary the numbers are coming out as if they were strings someone can help me , follows the code : txt file ` 0 1…
-
1
votes1
answer245
viewsDatabase in Tupla
I need a code that receives data (values) and prints them according to your key. Each entry corresponds to a given of a hypothetical person, which contains Age, Name, Sex, Marital Status, Number of…
-
1
votes2
answers109
viewsMultiple keys and values, Dictionary compreension
I have been playing with python, Dict and list compreensions. I made this little script: import requests url = 'http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv' resp = requests.get(url)…
-
1
votes1
answer55
viewsError in namespace when creating "Resource Dictionary ..." inside a folder
In an empty project (test - WPF Application) I test two scenarios. Scenario 1 Right click on the project Add Resource Dictionary ... I get the following: <ResourceDictionary…
-
1
votes1
answer186
viewsHow to assemble a dictionary from two arrays, one from keys and the other from Swift values
I have two arrays containing information of courts and players. Need to put in a tableview this data, being that the sections of the table would be the blocks and the values, of each section, would…
-
1
votes1
answer301
viewsInput, on the same line, of a string without spaces and another with spaces
My program asks that, at the entrance, on the same line, there be a string space-free name, the name of the applicant, and a string which can contain spaces desc, the description of the deposited…
-
1
votes1
answer164
viewsError in dictionary key
I am trying to store dictionaries in a list and then print according to the position in the list, however this giving an error in the key... Code below: nome = "nomedahora" cpf = "1421241"…
-
1
votes1
answer82
viewsImplement Dictionary as C#interface
I am trying to set a Dictionary on my interface, but it is saying that the main class did not implement Dictionary. Interface.Cs public interface IItem { event Action<string, string, string,…
-
1
votes1
answer250
viewsDictionary exercise
I can’t seem to solve this exercise. I need the letter indicating the type of service (E,R or F) to be indicated in the same line as the other information, however, according to the letter inserted,…
-
1
votes4
answers1960
viewsBack position in data JSON format or list with Python
I am working with data similar to the structure below: {"Id":1, "Data_inscricao":"2017-01-01", "Texto":"Loremipsum", "Numeracao":26, "Tempo":"25s"}, {"Id":3, "Data_inscricao":"2010-05-02",…
-
1
votes1
answer1149
viewsBrowse Python dictionary from the end
I wonder if there is a way to go through the keys of a dictionary backwards? For example, in a dictionary d1 ={1: [], 2: [], 3: [], ..} start with key 3. I know it is possible to go through from the…
-
1
votes1
answer304
viewsDictionary as input argument is being modified within the function
In the code below the dictionary used as input argument is also being modified by the function. I need to perform a deepcopy() at all times? def muda(a): a['valor'] = 50 return a dic1 = {'valor':…
-
1
votes1
answer1183
viewsHow to Separate Data in Dictionary from a . txt (Python)
I have a text file (attachment.txt), which I have to store in a dictionary, with Name as key and phone, value. the file has the following information: --- nome telefone --- Ailton-1197765445…
-
1
votes2
answers1795
viewsHow to create a PDF from Dictionary data extracted from a . txt (Python) file
I have a dict() with string data extracted from a arquivo.txt. dic = {} dic[valor[0]] = valor[1] print(dic) >>> dic = {'Almir': 44, 'Ana': 36 ....} I would like to save organized in PDF as…
-
1
votes1
answer326
viewsHow to change the values of a Hash?
I need a loop to change the values of this object { [ "Begin", "Dom" ] => 0, [ "Begin", "Seg" ] => 8, [ "Begin", "Ter" ] => 10, [ "Begin", "Qua" ] => 30, [ "Begin", "Qui" ] => 20, […
-
1
votes1
answer219
viewsDictionary and repeating structure
The problem asks me to count the size of holes in the text Exp: A, D, R, O, P has only one hole, and B has two I made the following code: qnt = int(input()) cont = 0 l = [] for i in range(qnt): txt…
-
1
votes1
answer682
viewsProblem with dictionary - Attributeerror: 'int' Object has no attribute 'get'
I’m starting to learn the basics in Python, and one of the examples about dictionary lists asks for something like this: inventory = {'a' : 1 , 'b' : 6 , 'c' : 42 , 'd' : 1 , 'e' : 12} def…
-
1
votes2
answers3000
viewsPrinting data from a Python dictionary
How do I print the data of a dictionary each in a column? For example: lanchonete = {"Salgado":4.50, "Lanche":6.50,"Suco":3.00,"Refrigerante":3.50,"Doce":1.00} for m in lanchonete: print (m[0]) I…
-
1
votes1
answer1071
viewsHow to create a dictionary and auto increment values?
I need to create a dictionary from a list of integers, where each key contains the value of the sums that are in the list: t = [[1,2],[2,1],[3,1],[4,1],[1,1],[2,2],[1,2]] dicionario = {} for i in t:…
-
1
votes1
answer641
viewsHow to create dictionary from lists
How to associate lists to keys and values to create a dictionary in Python? Is that the problem? I have a large csv file and I need to read the first line (I turn it into a list) that should be used…
-
1
votes1
answer2542
viewsAdding elements from a list to a dictionary in Python3
Good afternoon, I’m having trouble adding elements of a list to a dictionary. The list elements to put in the dictionary are: ['Joao', '83889023', 'Maria', '81944356', 'Marcos', '32258899', 'Ana',…
-
1
votes1
answer279
viewsCreate similar C# dictionary in Typescript?
I have the following dictionary in C#: Dictionary<string, List<string>> ls = new Dictionary<string, List<string>>(); ls.Add("chave1", new List<string>());…
-
1
votes2
answers824
viewsRead a csv file and add your data into a dictionary
I have a code where I will have a function that will pass the data from a csv file to a dictionary. The process will be to take the films with their respective notes and add to a dictionary relative…
-
1
votes3
answers73
viewsKey-value dictionary
Suppose I have the following dictionary: dicionario = {'exemplo1':1, 'exemplo2':2, 'exemplo3':3} How do I add a key-value without changing the ones already added? In case I want it to stay that way:…
-
1
votes4
answers361
viewsHow to count occurrence of strings within a dictionary made up of lists in Python?
I have a satisfaction research dictionary that the evaluator can evaluate up to 6 products. The program stores the evaluator, the refrigerant and the note for the refrigerant. And I have to show the…
-
1
votes1
answer327
viewsOrdering cards in Python
I have a list of the cards and the suit of a deck that I need to sort. Considering the correct order: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K And the suits: P(clubs). O(gold), E(sword), C(hearts)…
-
1
votes1
answer48
viewsOutput values are leaving without space
I have the following problem to solve: Cryptography (Greek: kryptós, "hidden", and gráphein, "written") is the study of the principles and techniques by which information can be transformed from its…
-
1
votes0
answers16
viewsCollect value from a dictionary
I’m in a project where inside the dictionary the key is a person name and its value is list. The list has values filled in as shown in the example: Ana:(3,5) - "Ana" is the key of the dicio and…
-
1
votes1
answer220
viewsAdd tuple in Python set
I am creating a graph with the following rules: The graph is a dictionary. The vertices are the keys of this dictionary and the values are the edges. Since I can have more than one edge for a…
-
1
votes0
answers81
viewsPython - Dictionary within list
I have a dictionary inside the list: A dictionary can be used to provide a "dependency table". For example, dependencies of disciplines in college. To do Calculus 3, I first need to do Calculus 2…
-
1
votes2
answers160
viewsComparison between Dictionary and List
I’m doing a show where the idea is to start by asking if the person is already registered, otherwise they go through one. I’m having trouble checking if the username is already existing, based on a…
-
1
votes0
answers39
viewsDoubt in dictionary - Python
Good morning! I’m trying to create a dictionary where it has some keys inside other keys, and each key contains more than one item. I have looked in several places but I can’t find anything about…
-
1
votes2
answers53
viewssaving Dict list on file
I have a function that saves a Dict in a file, but this is simultaneous, I mean, every time I have a new Dict. I couldn’t apply the concept of append to this problem. The Archive is being saved this…
-
1
votes1
answer715
viewsDoubt about the __dict__ method in Python
Well, I’m a beginner in Python programming and started studying object orientation. I came across the following code, which is very simple. class Pessoa: def __init__(self, nome, idade, altura):…
-
1
votes1
answer1167
viewsCreation of python Dict
Time, has a class that creates dicts and stores them in a list slot: class Pagina: def __init__(self, keys, palavras, tamanhoP): aux = list(zip(keys, palavras)) self.paginas = list() for i in…
-
1
votes1
answer85
viewsPython dictionary
The code below should count the words of the text and at the end show the amount of times each word appears in the text. I’m using the anaconda’s Spyder (Python 3.7). texto = """Caso tenha o estigma…