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
-
1
votes1
answer56
viewsProblem with dictionaries
Good afternoon! I am training my Skills solving some problems, I am a beginner in the Python language. I’ve been trying to solve the problem below for 2 weeks and can’t find a solution. Can someone…
-
1
votes1
answer60
viewsBest option to store (key, key and value) in C#?
I am working on a tool where the user inserts information and based on some calculations in the entered value it returns a fixed value description. Example: User enters the value 101. It value will…
-
1
votes1
answer56
viewsProblem to add data to a dictionary
I’m trying to build a function for calculating multi-note averages, but error occurs when I try to pass this data to a dictionary. The system claims that the class of data that I try to pass is not…
-
1
votes2
answers126
viewsHow to create nested and counting dictionaries from lists/tuples?
I have lists of sublists and tuples inside. I need to create a dictionary whose key is the car name and the value is a dictionary nested with the car model count. My lists are like this (it’s just a…
-
1
votes0
answers28
viewsHow to call data from a dictlist into code in the form of Checkbutton in python Tkinter
Reformulating everything, I created a new file from scratch called "dict_list_codigopenal.py", he is responsible for taking the file "cdp.csv" and read as spreadsheet, transforming into a Dict list.…
-
1
votes1
answer47
viewsSorted function referencing keys in a dictionary to define the sort criteria
dict = {'dc':20,'ba':10,'aa':5,'db':30,'za':1} dict_2 = sorted(dict.items(), key = lambda dict: dict[1], reverse = True) print(dict_2) When I place Dict[1] in the function argument I get the…
-
0
votes1
answer82
viewsHow can I interact with a class that is behind two?
Good night! I will explain the problem since the title is not suggestive of it. I have to develop an online shopping system, able to manage the purchases of each user. If you think about it,…
-
0
votes1
answer168
viewsReturning get_FIELD_display from a dictionary-transformed list (Django)
I wanted to turn the following list into a dictionary: lists py. status_list = ( ('c', 'cancelado'), ('elab', 'em elaboração'), ('p', 'pendente'), ('co', 'concluido'), ('a', 'aprovado') ) So I did…
-
0
votes1
answer102
viewsPython 3 dicts and zip problem
I’m having trouble with my job dict(zip(x, y)) when I pass as parameter the two lists (x and y) the zip does not create the list of the original size, randomly creates the list in the original size,…
-
0
votes1
answer1247
viewsSolve duplicate items in Dict in Python 3
I’m having trouble with my dict. I need it not to delete duplicate key values. I have a style tuple lista_tupla = [(1, [1, 2, 3, 4]), (2, [5, 6, 7]), (3, [7, 8, 9]), (3, [10, 11, 12]), (4, [13, 14,…
-
0
votes2
answers231
viewsMultidimensional array in C# equal PHP?
First time here on this forum, I usually use stack overflow but come on. My question refers to the array in C#: I’m more familiar with PHP and in php we can name our array indexes for example:…
-
0
votes1
answer256
viewsDictionary in python
Good morning! I’m having trouble breaking down the information and dictionary in python. My dictionary is a Biopython-generated dictionary like the one below: {'LastUpdate': '2016/11/11 04:34',…
-
0
votes1
answer37
viewsType of a data structure
I am trying to count the amount of dictionaries exists in a list. However the condition always of false in the if. >>> type(record['TranslationStack'][0]) <class…
-
0
votes2
answers3050
viewsScroll through a Dict until it is empty in Python
How do I go through while a list of values and keys is non-zero, just add the values (values()) in a list? The code I have is this: hey = ['item1', 'item2', 'item3', 'item4'] print("hey", hey) lol =…
-
0
votes1
answer105
viewsProblem in Dict class and merging large amount of elements per Python Dict
Hi, I’m having trouble with dict. I have two lists: lista1 and lista2, both the same size. When I execute the command: dicionario = dict(zip(lista1, lista2)) produces a dictionary "smaller" than the…
-
0
votes1
answer17
viewsError in Maproute configuration
The following error is returned to me: The Parameters Dictionary contains a null entry for Parameter 'numerodeserie' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.Actionresult…
-
0
votes1
answer901
viewsCheck if dictionary is null or empty?
In a return of a method I have a resulting dictionary, sometimes it may come empty, hence I’m having trouble identifying when it is empty or not. for(var i = 1; i <= this.last; i++) {…
-
0
votes1
answer986
viewsHow do I use the find function to find an entry in a Python dictionary (json)?
How to use the function find to search for a dictionary entry in Python (json)? Should I use json (loads) and json (dumps)? If I type, for example, "ma" the search result would show me "Cesar…
-
0
votes0
answers1237
viewsHow to add new keys to a dictionary?
Next, I’m doing a program that’s an academic control system, it turns out that when it comes to adding teachers, for example, it’s not creating new keys for teachers in the dictionary. He’s simply…
-
0
votes1
answer477
viewsHow to order a dictionary with a key
I have a dictionary as follows: dicionario = {(0,0,0):['alguma informacao']} how can I sort this dictionary from one of the key information? For example: dicionario = {(0,0,0):['alguma…
-
0
votes2
answers569
viewsDictionary file
I am trying to turn a file into dictionary but is giving the following error: Traceback (Most recent call last): File "C: Users taynan Appdata Local Programs Python Python36-32 Project CRUD…
-
0
votes1
answer57
viewsProblem to show the value in the dictionary that corresponds to the user’s response
bebidas = {'Suco de laranja': 5.99, 'Suco de uva': 5.99, 'Suco de açaí': 5.99, 'Coca Cola(lata)': 6.50, 'Vitamina': 7.50 } simounão = int(input('Olá, gostaria de ver nosso…
-
0
votes1
answer679
viewsReturn the smallest value - Python
from collections import OrderedDict #Pra poder acessar os elementos igual listas e tuplas. v v v lista_aberta = {(1,3): [1,2,3,4], (1,4): [2,3,4,9], (1,5): [3,4,1,7]} I need to check all the…
-
0
votes2
answers108
viewsOrder dictionary and display 20 first
I have a dictionary with words and their frequency. Of the kind: dic = {walt: 2, disney: 1, ola: 5, ...} To sort the dictionary I did so: aux = sorted(dicionario, key=dicionario.get, reverse=True)…
-
0
votes1
answer47
viewsExtract '_id' from load_response object
After post, I get an object load_response, in Dict format, with the following structure: {'_content':…
-
0
votes1
answer80
viewsProblems with dictionaries and lists - python
Hello, I have the following dictionary. datas = {'records': [{'createdTime': '2018-02-20T21:56:20.288Z', 'fields': {'publicacao': '2018-01-22'}, 'id': 'rec1c1c8qyIkdwyMD'}, {'createdTime':…
-
0
votes2
answers5301
viewsDelete value from a Python dictionary
I need to delete a key from a dictionary if a certain situation arises. I have this code: for i in dict.keys(dataClean): dataClean[i] = dataClean[i] - 1 if dataClean[i] == 0: del…
-
0
votes2
answers356
viewsCounter in a dictionary value
I am a beginner in programming and am doing an exercise in which I need to count the votes of certain numbers according to the number of the player’s shirt. For example, if I type in the program 23,…
-
0
votes1
answer100
viewsHow to remove repeated values from a dictionary?
For example: A = {2:5,4:5,7:8,9:8,11:10} Must return B={11:10} to remove the repeated values.
-
0
votes0
answers102
viewsHow to insert various user input values into Java dictionary?
I want to allow multiple pairs (key, value) to be inserted into a dictionary, in Java, from user-typed values. I made a loop for to try to insert but could not, because every time a new pair(key,…
-
0
votes1
answer137
viewsLambda function to return higher value from a list of dictionaries
Good evening. Could someone explain to me how the lambda function below works? I’m not understanding why it returns the highest value in the dictionary. Another thing I’d like to know, the 'x' is…
-
0
votes1
answer707
viewsIs there any way to compare all item values in a python dictionary?
Is there any way to compare all item values in a dictionary? For example: a = {'valor1': 4, 'valor2': 5, 'valor3': 4} b = {'valor1': 2, 'valor2': 2, 'valor3': 8} if a['valor1']*2<b['valor1']:…
-
0
votes1
answer329
viewsChange word in jars according to dictionary
There is an exercise that consists of typing an N number and then typing in N lines a word and a quality. After this I must type a sentence. If in this sentence there is a word that I had typed…
-
0
votes2
answers414
viewsStore a dictionary in a Python file
I have a function that counts how many times the words appear: def countWordExact(dataClean): count = {} dataFreq = [] for word in dataClean.split(" "): if word in count: count[word] += 1 else:…
-
0
votes2
answers1751
viewsMedium, Minimum and Maximum in a python dictionary
I have a dictionary like that: {walt: 0.942342, disney: 0.324234, robert: 0.562354, help: 0.546912, ...} And I do it to find the average and the maximum: media =…
-
0
votes5
answers714
viewsI want to turn a text into a list of dictionaries
I’m making a bot in python for twitter that posts news about Latin America, at the time of making the system that detects whether a news is new or not, I will save the news that has already been…
-
0
votes1
answer226
viewsAverage frequency using dictionary
I want to check the frequency of words returned in a book (format .txt) and divide this frequency by the number of chapters found, thus obtaining the average word appearance per chapter. The point…
-
0
votes1
answer73
viewsSingle values average filter in dictionary list
I have the following dictionary list in Python 3.7: a = [ {'linha': 0, 'porcentagem': 1.0, 'id': 3, 'nome': 'bruno'}, {'linha': 8, 'porcentagem': 1.0, 'id': 7, 'nome': 'teste'}, {'linha': 12,…
-
0
votes2
answers66
viewsVIEW DICTIONARY ALPHABETICALLY - PYTHON
I have a dictionary that has 2 keys (name, age), within each there is a list of values. I need to put the names in alphabetical order and that the ages accompany the respective owners. That’s the…
python python-3.x classification dictionaryasked 3 years, 8 months ago Henrique Marvin Souza da Silva 28 -
0
votes1
answer1445
viewsDraw an item from the List, and then draw another item from a list with the name that was drawn from the first list
Good morning, everyone. I have a master list called "Livros". I need to draw a name from that list Livros. After choosing one of the names, I need to draw again, but now I need to choose from…
-
0
votes1
answer32
viewsWhen creating a new pair in a dictionary lose the previous data?
I’m creating a Dict from scratch, but when I add some new pair, the old pair gets lost. If I try to print 'name' for example, it gives error. cidade = { 'nome': 'São Paulo', 'estado': 'São Paulo' }…
-
0
votes1
answer45
viewsPrint value of a dictionary
I have this issue to resolve, I need to display the note of the first name in the order of the flame, but I can only print the Key, the question is this: Make a program in python that prompts the…
-
0
votes0
answers36
viewsHow to update a key slice (key) of a Python dictionary?
How do I update just a slice of a key in a Python dictionary? I am scraping a page and would like to format the result so that my key is on the same line as my value, for example: Air Conditioners:…
-
0
votes0
answers157
viewsExtract numpy arrays from a dictionary iteratively
I have a dictionary of the following kind: data = {'neuron4':Numpy array, 'stim':Numpy array, 'neuron3':Numpy array, 'neuron2':Numpy array, 'neuron1':Numpy array} I tried to do something like for…
-
0
votes2
answers647
viewsCalculate how many times the values are repeated inside a dictionary KEY - PYTHON
I have a dictionary that is created from a select in the database, what I needed was to generate a metric from that dictionary Dictionary # cria dicionário do banco de dados com os valores lds_data…
-
0
votes1
answer59
viewsKeysorting using Ordereddict?
The code below shows that the elements are ordered with odd keys in descending order and those with even keys in ascending order, but are not being ordered according to the rule. from collections…
-
0
votes0
answers39
viewsExporting data to Firebase
I’m trying to export a Python database to Firebase. My database is a JSON in the following format: '{ "0":{ "country":"Italy", "description":"Aromas include tropical fruit, broom, brimstone and…
-
0
votes1
answer119
viewsPopulating a dictionary of dictionaries through a for loop
I’m trying to create a loop to add information in a dictionary. The most external key of the dictionary will be the name of a course, and the value will be another dictionary, there will be 6 keys,…
-
0
votes1
answer24
viewsHow to split the instance of a class through outrw
To be more precise, yesterday I opened a question asking for help in creating a class that acted as a creator of dictionaries, and promptly I was answered, follows the class: ` class tuplas: def…
-
0
votes1
answer79
viewsSlice and store Ict in pyhon
I have the following class: class Buckts: def __init__(self, keys, palavras, tamanhoP): self.listaBuckts = dict() self.keys = list(keys) aux = list(zip(keys, palavras)) self.aux2 = list() for i in…