Most voted "list" questions
A list is an abstract type of data that represents a sequence of values, in which the same value can occur more than once. The main ways to implement a list is through an array (array, vector or one-dimensional matrix) or a chained list.
Learn more…1,022 questions
Sort by count of
-
4
votes1
answer129
viewsDoubt how to display the name of a dictionary key
It 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
answer59
viewsHow to deal encapsulated a field that is a list of immutable elements?
Imagine that you have an object and one of its fields is a list of immutable elements. You want to make this field available to the clients of this object in a controlled way, after all a list can…
-
4
votes2
answers193
viewsDefine criteria for sorting a list of lists
I have a list of lists of strings. For example a list, in which the internal lists have size n=3: listEx = [['verde','preto','laraja'], ['rosa','lilás','azul'], ['bordô','cinza','branco'], [preto,…
-
4
votes2
answers98
viewsHow do I know if a value is higher or lower than another value in a list using recursion?
Being a classified monster with your name, attack and defense. ("medusa", 2, 5) or (string, int, int). And getting a list of monsters, how do I create a function that tells me if the monster I want…
-
4
votes3
answers341
viewsSort a list based on two different criteria using Sorted
I have a list of tuples and I want to sort them out, but that’s two different criteria. Each tuple has the following configuration: (peso, beneficio) The ordination I want to make is as follows:…
-
4
votes1
answer161
viewsOutput composite structures in Python in Google Colab
I 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…
-
4
votes2
answers54
viewsWhy does creating a list with the same generator only work the first time?
In Python 3.6.8, when I materialize the list, it is shown and erases. This is a bug or so it is? >>> vet_neg ['EH01', 'EH02', 'EH03'] Categories (3, object): ['EH01', 'EH02', 'EH03']…
-
4
votes2
answers100
viewsSort two lists simultaneously, by notes in ascending order, then by name
I have created two lists, one of notes and one of names. The program must sort notes in ascending order, but it must sort names as well. I tested it as follows: notas = [5, 7, 9, 3] nomes =…
-
3
votes2
answers4935
viewsSort List by decreasing values
I have an object Chromosome: public List<int> Rotas { get; set; } public int ValorFitness { get; set; } And I also have a list of that object List<Cromossomo>. I’d like to sort this list…
-
3
votes1
answer935
viewsDatabase query for a C#List
I need to make a query at the bank, I made this code for connection, but I do not know how to proceed to put this information in a list<String> SqlConnection conexao = new…
-
3
votes4
answers3380
viewschange class of the clicked element
so guys I got a list: <ul class="nav nav-tabs" id="myTab"> <li class="active"><a href="#novas"><span class="badge badge-info"><?php echo $qtd_novas ?></span>…
-
3
votes2
answers3168
viewsCount duplicate values in list
I have a ArrayList with multiple numbers inside it. I need to identify how many times each number appears and then eliminate redundancies. I was able to eliminate redundancies, but I’m having big…
-
3
votes1
answer625
viewsSerialization of lists in C#classes
Good afternoon guys, I’m running an Nfe project for emission, so I opted, after searching use class serialization to mount xml. Everything works very well, from a class structure that defined the…
-
3
votes3
answers8198
views -
3
votes1
answer1658
viewsChain list ordering
I am doing a job that I need to create a chained list and order it in ascending order, performing my tests I realized that I am losing the reference to a node, the problem may be logical but I am…
-
3
votes4
answers8751
viewsChange color marker li
Hello! I wonder how I do to change the color of the marker ball <li> via CSS. From what I read on the Internet, so far I’ve only been able to do this using an image to replace the ball.…
-
3
votes2
answers1697
viewsRemove element from a chained list
I am implementing a chained list of type "with head". It follows struct referring to the list and its creation in main() struct lista{ int info; struct lista *prox; }; typedef struct lista Lista;…
-
3
votes1
answer8989
viewsHow to add an element to a list?
What is the correct syntax to call the method Add_Pessoa class ClsPessoa by a List? public class ClsPessoa { private static string PSTR_Nome = ""; private static DateTime PDT_DataNascimento; private…
-
3
votes1
answer106
viewsFood list gives "Index out of range"
In my system, I need to return to the number of questions that the student missed on a particular topic. To achieve this, I tried creating a class that has two attributes: Tema and QteErros and…
-
3
votes3
answers72
viewsMake copies of lists at certain positions with Python
Hello, please, I would like to copy a certain list in python. The total list size is 150 and I wish to remove the last 50 elements from the list. Here I will represent a list 100 times smaller, ie…
-
3
votes3
answers321
viewsPass List as LINQ expression parameter
I have a LINQ expression where the result is saved in the variable query, which is transformed into a list, this query returns a series of "RA attributes". I would like to pass this list of…
-
3
votes2
answers423
viewsHow to manipulate instance properties of a class that is in a List<T>?
I have a class called Pessoa, this class has two properties Nome and Idade, I am using a List<T> to manipulate data, I know I can manipulate data like string or int creating a…
-
3
votes2
answers297
viewsList Comprehension for this case
How can I use comprehensilist on for that case: >>> a = 'A' >>> lista = [1, 2, 8, 5, 10] >>> l = [a, num for num in lista if num%2 == 0] File "<stdin>", line 1 l =…
-
3
votes2
answers3501
views -
3
votes2
answers188
viewsReceive 2 parameters when entering a key parameter
I have a code that is related to 2 values, for example: 1253 (code), São Paulo (first value, in this case the state), and Osasco (second value, in this case, the city). I wonder if there is some way…
-
3
votes1
answer466
viewsReload Datagridview in C#
I am creating an event of a button in which it creates a Product object and adds in a list of Products and using this list to fill the Datasource of a dataGridView, but Datagridview keeps appearing…
-
3
votes1
answer373
viewsHow to concatenate two lists efficiently?
Aiming at the union represented by the figure: In view of the structure below: TMyRecord = record Index: Int64; Kind: TMyEnum; Value: String; end Having two lists…
-
3
votes2
answers331
viewsSave list in file
I have an exercise that I register trucks, cities, loads through a list, but I’m not able to save in a file (it’s the last function) when I select the save option(#7), it closes the program. What am…
-
3
votes2
answers552
viewsHow can I "skip" elements of an array when I use "list"?
I got the following array $array = [25, 'Wallace', '26 anos', 'linguagens' => ['PHP', 'Python', 'C#'] I’d like to use the function list to be able to capture some elements directly into…
-
3
votes2
answers312
viewsReplace list() by placing value in each index of an array
So I was browsing php.net when I came across List() and went to see what it was for. Then they gave me the following example: $info = array('Café', 'marrom', 'cafeína'); list($bebida, $cor,…
-
3
votes1
answer2685
viewsC# Convert object to an unknown list of objects
I have a question here. I have an object (Object) received by parameter. It can be a single object or a list of objects (List). Can I convert the object to a List object WITHOUT RECEIVING THE TYPE…
-
3
votes2
answers599
viewsList of square roots
How can I make a function that takes a parameter n, return a list of the first n square roots, using higher-order functions, in Python. As shown below: [sqrt(1), sqrt(1)+sqrt(2),…
-
3
votes2
answers6824
viewsAutomatically create vector in Python
I’m new to Python and need help with the following: I have a variable (x) that takes an integer value. I want this variable to be used to create a vector with 1 row and (x) columns. This vector must…
-
3
votes3
answers16319
viewsConvert from string to list?
I needed to pass a string of the kind: 0.4350 0.8798 0.0099 1 for a list [0.4350, 0.8798, 0.0099, 1] with a script simple. How can I do it?…
-
3
votes6
answers2251
viewsRemove all elements from an array that already exist in another
I have two arrays with javascript objects: var a = [{objeto1}, {objeto2}, {objeto3}, {objeto4}, {objeto5}]; var b = [{objeto1}, {objeto2}]; How to do what is in the array b exit the array a?…
-
3
votes3
answers386
viewsUse of the split method
Good morning guys, sorry my ignorance for the simple doubt. I’ll get right to the point. I have a list of alerts List<Alertas> alertas; This list there are several messages sent to some users,…
-
3
votes1
answer988
viewsSearch for List Element
I want to search an element of a list through a name (character vector). I get the name (espm) in the function and start to search. The problem is that the function always tells me that "There is no…
-
3
votes1
answer403
viewsHow to use Java 8 Stream in an Object[] list
Imagine the following scenario: A list of Object[]. Something like that: List<Object[]> lista = new ArrayList<>(); Object[] dados = new Object[3]; dados[0] = 1; dados[1] = 20; dados[1] =…
-
3
votes2
answers936
viewsChained list: how to modify data from a list without changing the others?
I have a for that generates a list of data lists lista[[...], [...]] Inside the "daughters" lists may or may not have other lists lista[['dado11', 'dado12', [link1]],['dado21', 'dado22', [link2]]…
-
3
votes2
answers5175
viewsCopy a List to another List without dependencies
How do I copy data from one list to another in a way that is independent of each other? I have a list<> of a class I created where the data inserted in it, appear in a listbox, and I wanted to…
-
3
votes1
answer1959
views -
3
votes2
answers74
viewsHow do I stop "for" when I find an item in the list?
I have the following code: Console.Clear(); Console.Write("Nome da moto:"); string nomem = Console.ReadLine(); for (int i = 0; i < ListadeVeiculos.Count; i++) { if (nomem ==…
-
3
votes2
answers454
viewsHow to clone a list with Python 3?
From list m: m = [[' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' #…
-
3
votes1
answer973
viewsWhat is a "definition list" and how are these tags used <DL>, <DT> and <DD>?
As far as I knew in HTML there were only two types of lists. Sorted Lists <ol><li> and Unordered List <ul><li>. But apparently there is a third type of list, which is the…
-
3
votes2
answers64
viewsAutomatically add all Environment elements to a list
Suppose my Environment contains the following objects (fictitious names): abcd # numeric efgh # dataframe ijkl # matrix mnop # character My goal: put them in a list automatically without having to…
-
3
votes1
answer47
viewsCross-Reference with pointer array
I’m creating a cross Reset of a pointer vector that calls a simple chained list. Goal is to type a sentence and decompose your words, placing them in each vector position according to their…
-
3
votes1
answer238
viewsSlicing String and Saving the Slices in a PYTHON List
Hello, I would like to understand a little more about strings in PYTHON. I’m developing a program, which consists of: Pick up a STRING Separate STRING from 3 to 3 characters And store each part in a…
-
3
votes2
answers301
viewsChanging data types in a Python list
I have a list x, with 10 numbers, being all of them whole. I’d like to turn them all into numbers like float, but I can’t perform that conversion. Code: lista = [1,2,3,4,5,6,7,8,9,10] for i in acs:…
-
3
votes3
answers608
viewsLists repeating last added item
was studying about the lists in C# and I couldn’t understand what was wrong with my code (probably going to be very basic), all the items are the same as the last item added. I simplified the code…
-
3
votes1
answer122
viewsC# How to change value within Parallel.Foreach
I am performing a processing inside an array of strings (lines of a file . txt). For performance reasons, I’m using the Parallel.ForEach, but there was a need to change the values of some lines that…