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
-
1
votes0
answers169
viewsReturn list in an array - Webapi C#
Good guys. I need to return a list of courses linked to a particular student, this list will be consumed through the get of a Webapi. I have the classes "student", "course" and "cursoAluno" (tables…
-
1
votes0
answers306
viewsSearch for an item in the Aspnet mvc List
I have a controller, in this Controller has a action List, to which it returns all suppliers. In the view List, I created one input type="search". I want that when searching a name in this field, it…
-
1
votes1
answer61
viewsreturn a list of numbers that are in sequence
I’m trying to make some list go through and make another one come back with the numbers that are in sequence. My list is returning empty. Ex: lista=[1,2,3,5,9,10] returns nova_lista=[1,2,3,9,10]…
-
1
votes2
answers1715
viewspython list problems
I’m trying to solve this problem in python: Make a program that loads a list with the models of five cars (example of models: FUSCA, GOL, VECTRA etc). Upload another list with the consumption of…
-
1
votes1
answer112
viewsWhy do lists (arrays) behave differently than common variables in Python?
Two examples that I think defines my question well, the first is the function: a = [1, 2, 3, 4, 5] def soma(l_item): l_item[0] += 10 soma(a) print(a) >>> [11, 2, 3, 4, 5] It is changed by…
-
1
votes2
answers115
viewsRemove only strings from a list
I have the following code: Lista_1 = [10, 3, 6, 27, 'Maria'] Lista_2 = [37, 8, 45, 80, 'Jose'] Lista_3 = [43, 67, 99, 3.456, 'Pipoca'] Lista_4 = [432, 456, 333, 538, 'Bala'] Concatenating lists…
-
1
votes1
answer143
viewsVariable changes value when calling function
I created a variable v, who receives n random numbers. when create another variable by calling a function and passing v by parameter, the v mute. n = int(input("Entre com o tamanho de vetor: ")) v =…
-
1
votes1
answer151
viewsDynamic matrix in C#
What would be the best way to create a dynamic square matrix ? An array that increases row and column as elements appear to be inserted into the matrix I found some comments on the internet saying…
-
1
votes0
answers25
viewsInventory of Archives
I am learning to program and I would like to know if you have any way to create in python a list of network file inventory, contento as follows situations: Network Path: rg2srv0164…
-
1
votes1
answer275
viewsSort class list in Python
I have a class defined as follows:: class Cromossomo(): def __init__(self, cromossomo, comprimento): #Construtor self.cromossomo = cromossomo self.comprimento = comprimento From it I have a list of…
-
1
votes2
answers3307
viewsConcatenating two linked lists into C
I’m starting my studies on dynamic structures in C and I’m having trouble making a code to concatenate two lists. The paint part on the screen the contents of the lists is working, but when…
-
1
votes2
answers379
viewsHow to search for partial text in a string list?
I have a list with several text elements, and I would like to know how I can find one of these elements by searching for a part of the text and not by the exact text. Example: Lista = ['Jorge…
-
1
votes2
answers355
viewsGet CSV list with Python
I have a CSV file with more than 9000 lines. I need to get a list with only one data of each line. An example is the following: 01/02/19,carlos,casa,rio 03/05/18,luis,carro,maceio…
-
1
votes2
answers205
viewsStore read names in a list and randomly choose one of them
How do I, among the students I type, he draw one within the range? In the code below it does not draw, returns me only the last name: from random import choice for c in range(1, 4): aluno =…
-
1
votes1
answer924
viewsHow to print a list in C?
/* define a struct TAD lista */ struct lista { float info; /* dado */ struct lista *prox; /* ponteiro para o proximo elemento */ }; typedef struct lista Lista; I have the struct above and the…
-
1
votes2
answers86
viewsHow would you solve this simple question?
I was solving a simple Python question The program asks for three numbers and returns in descending order - I decided to do it using a list, like this: numeros = [] for i in range(0,3):…
-
1
votes1
answer677
viewsCreate Chained Dynamic List
I am learning how to work with chained lists. In one of the videos classes I attended, the teacher suggests the following code: struct celula { int info; struct celula *prox; }; typedef celula Elem;…
-
1
votes1
answer5282
viewsPython - Sort string order by order of increasing number of letters
Having the following list: lista_nomes =['Manuel', 'Laura', 'Antonio', 'Jasmim', 'Maria', 'Silvia', 'Lu', 'Pancrácio', 'Diogo', 'Ricardo', 'Miguel', 'Andre'] And wanting to order it by order…
-
1
votes1
answer46
viewsPython - Complete list of each writer, along with the acronym of each person (first letter of name and surname)
Based on the list of writers described below, I have to manually create a list in which each element is a list of two elements, name and nickname. Here is the list: escritores = [['Pedro', 'Tamen'],…
-
1
votes1
answer56
viewsPython recursive function printar correctly
I am starting in python and I would like the result of my execution to be as follows: [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 9 ] ] [ ’ ∗ ∗ ∗ ∗ ’ , ’∗ ∗ ∗ ∗ ’ , ’ ∗ ∗ ’ ] But I’m not…
-
1
votes1
answer68
viewsList C# missing what has already been added
I’m a beginner and I’m developing a shopping cart. The routine I thought was: Every time I click the add button, the product is sent to the controller via ajax request. I already have a list created…
-
1
votes0
answers61
viewsReturn lower value from a list - Lisp
I want to return the smallest value of a list with an iterative function in Lisp. The code I have is this:: (defun rmin (lista) (let ((minim (first lista))) (loop for a in (lista) (if (< a minim)…
-
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
votes0
answers137
viewsVault Secret Issue - OBI 2017
I’m solving the following OBI problem: https://olimpiada.ic.unicamp.br/pratique/p1/2017/f1/cofre/ Vault Secret The secret system to open this vault is quite complex. Instead of rotating a button…
-
1
votes1
answer218
viewsSimplest way to create circular array in Java
I’m looking for a more streamlined (clean code) way to create a circular array in Java. For example, given the following list: ArrayList<String> lista = new…
-
1
votes1
answer105
viewsfind least repeated value in list
I have to draw a thousand numbers between 0 and 100, and point out which numbers were more/less repeated and the highest and lowest value, but I could not find a way to show what was less drawn.…
-
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
answer1233
viewsExcel: load list of names according to the selection of another list
in the school I work has a file with the class spreadsheets (the name of the spreadsheet is the class number. Ex: 100, 200, ...). I need to make a spreadsheet in this same file to generate…
-
1
votes2
answers2087
viewsHow to draw numbers from a list, randomly and without repetitions?
How do I draw 9 numbers in a list of 15, without repeating the numbers drawn? I use Python 3.8. import random for c in range (1, 16): n1 = str(input("Digite um nº: ")) l = [n1] random.shuffle(l)…
-
1
votes1
answer52
viewsHow to select a random string from a list in C#?
Basically, I intended to choose a Random Question from the 'Question List', and when I write the code, it gives me an error in the bold part (the one inside the **). private void EscolhaDaPergunta()…
-
1
votes2
answers516
viewsRemove items from one list that are in another
I have two lists with values, and when I try to search an item from one to another, to see if it exists, it’s returning False even if knowing that the item exists in the searched list. proc =…
-
1
votes2
answers2837
viewsInsert item into html list, using javascript
Hello, I’m wanting to insert an item(li), into an html list(ul) This item is an object, or property of an object. PS: I want a list to appear for example containing this data of the object I created…
-
1
votes2
answers87
viewsHow to remove all elements from a list equal to a certain value
How to remove all values from a list that will have the same meaning for example: array = ['sim', 'sim', 'sim', 'sim', 'sim2', 'sim3', 'sim4'] Is there any way to make a looping loop as long as…
-
1
votes2
answers55
viewsHow to catch the smallest hints from the list, but only from Dice 0 to 1
z = [-4, -1, 0, 0, 0] F1 = [ 9, 1, 1, 0, 18] F2 = [ 3, 1, 0, 1, 12] #Pega a posição do menor valor das listas n_min_z = min(z) n_min_F1 = min(F1) n_min_F2 = min(F2) #Guarda a posição em uma variavel…
-
1
votes3
answers166
viewshow to find the indexes of an item that repeats in a list in Python
have a list l = [1,6,6,2,3,6] and I want to form another with all the indexes of the element 6. In this case, the second list should be l2 = [1,2,5], however, when I try to use the l.index(6),…
-
1
votes1
answer248
viewsInsert rownames/ values as a new variable in a list dataframes
Suppose n dataframes within a list. Each of these dataframes has different lines. For example, in a dataframe, rownames are characters (make of cars) and in other, rownames These are hospital…
-
1
votes0
answers133
viewsExtract only numbers from a list
I’m using the package on the R fbRads to collect data from Facebook Ads. However, when I turn it into a data frame, I get a list of the values, rather than the numerical value. How can I separate…
-
1
votes2
answers83
viewsFunction that creates list inside list
def add_divisors(list_num): final_list = [] divisors = [] for number in list_num: for x in range(1, number+1): if number % x == 0: divisors.append(x) final_list.extend(divisors.copy())…
-
1
votes1
answer1396
viewsSort list with Python + Django
Good afternoon guys, I have a problem, register by the Django admin a video that should be sent to my template, however I need these videos to be ordered by the field position that I have in my…
-
1
votes4
answers241
viewsFilter list of python objects
Hello, I’m new to Python and I’m having doubts to filter an object from a list. I have the following list: [{ ID: 1, Name: 'Teste 1' }, { ID: 2, Name: 'Teste 2' }] And I am wanting to realize a…
-
1
votes3
answers66
viewsHow to remove values that are in another list?
I have two dictionaries, one with available schedules, and one with scheduled schedules: schedules_dict = {1: ['00:00'], 2: ['00:30', '00:45'], 3: ['00:00', '00:30', '00:45']} appointments_dict =…
-
1
votes1
answer33
viewsScroll through a list to get the current element and the next
How can I implement two for(Teste teste : lista) {} to go through the same list? And the second foreach would always have to look at the next item on this list? I tried that way but he always…
-
1
votes3
answers63
viewsHow NOT to separate a number of two or more digits when adding to a Python list?
I have a problem that, when iterating over a string and adding only the numbers in a list, a number (for example 13) eventually becomes ['1', '3']. How to get around this and make the number…
-
1
votes2
answers61
viewsRemove items from a list that are part of a character or part of a certain class
Consider the list: mylist=structure(list(quem = 1:10, quer = c(1.1, 2.1, 3.1, 4.1, 5.1), isso = structure(list(X__1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), X__2 = c(123, 456, 789, 1122, NA,…
-
1
votes1
answer75
viewsHow to obtain items that multiple lists have in common
How to do for when there is no common item, launch warnings? List 1, 2 and 3 have different index numbers. def compabilitySorter (lista1, lista2, lista3): listCompatible=[lista1, lista2, lista3]…
-
1
votes1
answer115
viewsHow to find the lists that have a certain desired item
I would like to check if a specific item in a list is equal to "Aberta". def mostrar(): with open("ficheiro2.txt") as arquivo: i=0 for linha in arquivo: linha = eval(linha) if linha[i][2]=="Aberta":…
-
1
votes1
answer812
viewsIs it possible to have a split() with two or more conditions in Python?
Good afternoon staff, developing a code, I came across a question: I would like to realize a split() with n conditions? Or any efficient way to do? For example: I am requesting for a user to enter…
-
1
votes1
answer76
viewsAdd inside a new position array in javascript
var produtos = new Array(); produtos = [{"Id":2,"Nome":"X bacon","Valor":12,"Quantidade":1},{"Id":3,"Nome":"Lucas","Valor":9.97,"Quantidade":1},{"Id":4,"Nome":"teste","Valor":5,"Quantidade":1}] I am…
-
1
votes4
answers3686
viewsSumming value by value in an array with Python
I need to sum up all the possible values within one array to find out where an error is in a database. Code until then: valores =…
-
1
votes3
answers1988
viewsEmail validation function
I need help with this code 'cause I’m racking my brain and I can’t fix it. You first enter the number of emails you want to enter with input. Then you type the emails according to the number you…