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
votes1
answer32
viewsHow to randomly rearrange a list of Strings and select one element at a time without repeating the value contained in the list?
I am developing an application in Android studio in Java language and need to know how to solve my problem. I have a list of String: List<String> valores = new ArrayList<>(); Then I…
-
1
votes1
answer650
viewsC# - Windows Form how to search in a Datagridview
I have a datagridview which is populated from a list with data. When starting the screen I make a SELECT searching all bank records. How do I perform a search on this list and datagridview? My…
-
1
votes1
answer252
viewsSee which elements of the list are primes
Hello, I am making a list of exercises and I came across a question consisting of reading the elements of a list and determining how many are cousins. I could only do the function to calculate 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
answer158
viewsInsert object from a Linkedlist to a Linkedlist from another class
I have two classes in my project: Cars and Cars. At first, I have a Linkedlist stated as follows: private LinkedList<Carro> carros = new LinkedList<Carro>(); Then I have methods of…
-
1
votes0
answers109
viewsTAD Alphabetical Order Method List
This is the first topic I’m posting, I’d like you to help me with this problem. The problem is based on ordering data entered in a Dynamic List (C#) according to name (Alphabetical order). As it is…
-
1
votes2
answers1434
viewsHow to make the user return the specified condition when the same type wrong?
In Python, when the user type a non-existent option, how do I ask him to type again one of the desired options? Make a program where the user can type several values and register them in a list. If…
-
1
votes1
answer2252
viewsPython Login and Registration System
I am trying to develop a simple registration and login system using text files, but at the time of login is giving error. I believe it is in the variable "Registered", because from what I understood…
-
1
votes2
answers108
viewsHelp in python Lists
Good night I’m having a hard time with this: [['1', 0.0, 1.8], ['1', 3.0, 2.0], ['1', 5.0, 1.5], ['1', 6.0, 1.5], ['1', 9.0, 3.0], ['2', 0.0, 1.8], ['2', 1.0, 1.5], ['2', 2.0, 1.5], ['2', 3.0, 2.0],…
-
1
votes3
answers184
viewsFunction to duplicate a Python list
Guys I have this list: lista = [['10616558', 0], ['2856466', 1], ['9715350', 2], ['9715350', 3], ['9715350', 4], ['10720706', 5]] The first element is any string, and the second is an index. I need…
-
1
votes3
answers224
viewsSelection of the first number from a list
Hello, I have a problem that I believe is relatively simple in python, but I can not solve it. I have a list of values that vary in positive and negative numbers. And I need to select from that list…
-
1
votes2
answers376
viewspython search
I need to create a binary search function. The function should look for the target in the list. checks if list[middle] is the number I want. If it is, it returns True. If it is not, and the middle…
-
1
votes1
answer528
viewsHow to show/display a list of strings in Chained List?
Guys, I just started to learn Chained List in C language. Why didn’t my code display full string on the screen? It is displaying only integers or 1 character. The problem is in the display part (the…
-
1
votes2
answers3082
viewsPython data entry with multiple lines
I would like to understand how to input several data (int, float, str...) per line but repeatedly (i.e., in several lines) so that I can save each given input. I understand that I will have to use a…
-
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
votes3
answers1495
viewsMerge elements from a list with the last different tab
An exercise in a book I’m studying has the following question: Suppose you have a list value like: spam = ['apples,'bananas','tofu','cats] Create a function that accepts a list value as argument and…
-
1
votes1
answer848
viewsAdd an element that is not in the array
I’m new to C, I’ve been trying to find a way to do this program but always returns a result that I can’t understand when printing the array for visualization. Example of entered values:…
-
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
votes0
answers36
viewsList indexes
Good afternoon, this week my teacher passed me the question of scheduling a phone book. I did with dictionary but he had me redo with lists. There’s a part where I have to remove a contact from the…
-
1
votes1
answer223
viewsHow to run a MERGE object list by returning the Update or Insert Id?
I have the following scenario; I need to make a INSERT or UPDATE from a list of List<PRD_ARTIGO_VARIANTE_VALOR>, my doubt is whether there’s any way I can get past the list of a single time by…
-
1
votes2
answers70
viewsLoop for inside a list with a group argument function
I have this data: df_1 <- data.frame( x = replicate( n = 3, expr = runif(n = 30, min = 20, max = 100), simplify = TRUE ), y = as.factor(sample(x = 1:3, size = 30, replace = TRUE)) ) And this…
-
1
votes1
answer244
viewsSort lists without Sort
I’m trying to solve an exercise, but I’m not getting any results yet. I’m new to language. '''Define a merge function that does the following: Given two ordered lists L1 and L2, returns an ordered…
-
1
votes2
answers5692
viewsHow to print all the contents of a list in Python
How do I print contents from a list? I want the output to look like this: Indice: 0 1 2 ... likes: 0 0 0 ... A post is represented as an element of a list. The list index indicates the post number.…
-
1
votes1
answer50
viewsHow to know the last element in a Qlistwidget?
I have a Qlistwidget called list_toMerge with some items added, then I created 2 buttons to change the order of the items. The up button and the down button. First look at the code in the up button:…
-
1
votes1
answer370
viewsCreate sublists in python
I created the following code: self.buckets = [[], []] for i in self.keys: for ii in self.lista: if i % len(lista) == ii: self.buckets[ii].append(i) That adds the elements of a list in the case…
-
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
answer180
viewsHow to add an array inside a python Matrix
Hello I’m having a problem in python I’m taking an excel a Matrix of 15 columns and 3 rows, so I’m reading excel with pandas and did that while below to read all columns and all rows: import pandas…
-
1
votes2
answers82
viewsList ordering returns "None"
I’m doing a program that renders keys to the euro millions, but the keys are None, what is my mistake? import random print('Chave do Euromilhões') num=…
-
1
votes1
answer348
viewsHow to calculate polynomial roots with a list?
I’m having a hard time with a university job and I’ve come to ask for your help here. I have two lists of candidate values to be roots of a polynomial. listaDivisoresP = [] for i in…
-
1
votes2
answers87
viewsHow to define which inputs will be accepted by the code?
I have a code where as the user enters data, I want to create a list that will be used for operations later. Output input would be the key "f" interrupting the repeat structure and initiating…
-
1
votes1
answer513
viewsCount number of occurrences of a number
Program that has only one function, besides the main program, that will receive as parameters an integer number x, a sequence of integers L and a natural n, representing an item x that must have…
-
1
votes2
answers159
viewsDecoding a conversation
Problem: A code has been created between friends to encode conversations. There is a code relationship between letters and numbers as shown below. It is necessary to create a function called…
-
1
votes2
answers131
viewsI am training the basics of Javascript and need help in a To-Do List
I’m a Javascript beginner and I tried to make a To-Do List. Basically, it is a code that creates an item within an unordered list using the text inserted in an input. I was successful in the process…
-
1
votes3
answers84
viewsFind largest element index in the list
I am putting together a code that creates a list with 3 items of purchase, and within this list some tuples with the names of the products and the respective prices. I want to find the lowest price…
-
1
votes2
answers66
viewsobject1 += object2 is different object1= object1 + object2 in python(3.8)?
objeto1 += objeto2 and objeto1= objeto1 + objeto2 give different results even though the two forms seem equivalent. Could someone explain to me what I’m not realizing? class f(): def…
-
1
votes1
answer196
viewsHow to remove an object from a list chained by the value of the attribute in C++?
What is the best way to remove an element from a list by the value of its attribute, without knowing exactly its position? I realized that the method Erase remove by position, and tried to use along…
-
1
votes2
answers69
viewsOFF - Is it possible to print a list value by passing its index?
In the code below I,when I come out of the while,I print the athlete jumps data, along with the average of the same. In the loop for,I print out all the jumps of the athlete, 'Cause I wanted to do…
-
1
votes1
answer244
viewsError involving Nonetype
I made a very simple code to simulate lines in python: lista = [] def a(lista): return lista.append(str(input('Nome: ')).lower().strip()) def b(lista: list): if len(lista) == 0: print('A lista está…
-
1
votes1
answer94
viewsStudying lists
I have two lists, the first call from cadastro and the second call from entrada. I remove an item from the list entrada and then I want to return this item in case it’s on the list cadastro, but I…
-
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
votes1
answer38
viewsHow to use for comparing a specific index?
In function bonAppetit, i want to pick up only the content k (in the case k=1 and the value is 10), and see if that number is less than or equal to b. Only my program is running the whole list. def…
-
1
votes1
answer56
viewsPrinting a permanent array in html
Good morning , I am developing a registration system, but after printing the data on the screen when reloading the printed data disappear. Any solution? Grateful. var aluno = []; var dados = ["Nome:…
-
1
votes2
answers195
viewsHow to return a list where the size is set according to a number typed in the python input?
I would like the code I wrote to return a number of tuples according to the value entered in the input, for example, if the input is 3, the return will have to be 3 pairs of tuples. The following…
-
1
votes1
answer50
viewsHow to access the index correctly for data in the same file?
I have a file txt file.: >gb:KX262887|Organism:Zika virus|Strain Name:103451|Segment:null|Subtype:Asian|Host:Human GTTGTTGATCTGTGTGAATCAGACTGCGACAGTTCGAGTTTGAAGCGAAAGCTAGCAACAGTATCAACAG…
-
1
votes3
answers253
viewsHow to resolve "Valueerror: max() Arg is an Empty Sequence" error when the list is empty?
This error appeared when I was testing my program, more precisely when the values of input do not satisfy the conditions imposed: n = int(input()) listaVelocidade = [] for _ in range(n): velocidades…
-
1
votes0
answers66
viewsActivity Lists in C
I received the following activity in the topic of Lists in physical contiguity: "Complete the attributes of the contact list structure in the file list_contacts.h. Create a contact list file. c and…
-
1
votes1
answer74
viewsHow to generate a new list from another Python list?
I’m having trouble performing list operations in Pyhton. I have a list of values. frequencia = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,…
-
1
votes1
answer44
viewsMerge lists based on key column value
I am converting 2 dataframes into 2 lists. And I will group them by the CNPJ_UF_MES column (always the 1st column of each dataframe. In the real example, I will join more than 2 dataframes. After…
-
1
votes1
answer67
viewsCombination of a numerical list with limiter (Python)
I am generating all possible combinations within a list, but I have not found any that would satisfy all my needs, being them: Result in list format; Lists with repeated items are valid; Completely…
-
1
votes1
answer28
viewsWhy do I still have access to the current state of the object in this case? [EXAMPLE C#]
A very basic doubt, but it’s bugging my head. I have the following code snippet: A class that receives a list as a parameter in the constructor: public class MinhaClasse { IList<int> Items;…