Questions tagged [list]

The list tag may refer to: a linked list (an ordered set of nodes, each referencing its successor), or a form of dynamic array. Not to be used for HTML lists, use [html-lists] instead.

1
vote
2answers
42 views

Java, nested loop, improve performance

I need to fill the List of iterations (task) according to the picture. To performs task, from hi until lo, the difference generate operations factorial order n!. Now, I dividing task like picture. ...
-1
votes
2answers
27 views

Python: How do I print out values with their corresponding keys and sort them?

My code is supposed to create another dictionary out of the existing dictionary of synonyms, with synonyms 7 or fewer characters removed, using the function called remove_word() and taking the ...
0
votes
1answer
7 views

Trying to position Flutter List to bottom of screen

I'm trying to position a List (puzzlePieces) at the bottom of the container on the screen. I've tried various alignment and position options, but most widget children do not accept a List. I would ...
0
votes
0answers
11 views

Changing a value in a matrix then adding to a stack but two values added are the same in stack?

So I'm trying to load up my Stack which is just the regular implementation used for a Stack as in it's a list and when I add I use the append function. I'm trying to add two matrices each differs by ...
0
votes
1answer
6 views

Yaml: structural considerations (map vs list elements)

Are there significant differences in usability between the two options below that I'm overlooking? Pitfalls I should consider? Each can be addressed easily enough, iterated over, etc. I feel as ...
1
vote
1answer
37 views

Conditionally add named elements to a list

I have a function to perform actions on a variable list of dataframes depending on user selections. The function mostly performs generic actions but there are a few actions that are dataframe specific....
0
votes
1answer
17 views

Shiny App Error in ObserveEvent? Error in [.default: invalid subscript type 'list'

I am writing a Shiny App, part of which includes the user inputting text to mimic R code and the app itself picking out certain words from this input to print a vector related to what the user is ...
0
votes
1answer
31 views

UWP write List<T> to a File

I'm trying to write a file in an UWP app that includes the items in a List of objects. I write the file, but it only includes the first line. Here is my code: List<OPSDATA> SortedList = ...
0
votes
2answers
46 views

Haskell list filtering with two arguments

I have to write a function, which filters with one argument that results True, then filters with another argument which results False I tried this: selectUnless :: (t -> Bool) -> (t -> Bool)...
1
vote
1answer
26 views

Attempting to create a custom List Class with Constructor

I'm trying to create a customized list class with a constuctor that has a string parameter. I have a string field that has several values imbedded within it. If it were simple, I could just to a ...
0
votes
1answer
32 views

How to apply a list to a larger set

How can I apply a list of x names to a larger list of items of equal length (or dataframe rows)? I have a dataframe of x rows and I need to apply a set of y names to the frame. How can I go about ...
0
votes
1answer
35 views

Parse 2 lists and create a comparison table

I am working on a screen which provides comparison between 2 lists basically. I have a class RateFactorItem, which contains a Name property and a List of ProductValues. public class RateFactorItem ...
0
votes
1answer
34 views

How to force a instance attribute to always be a list?

I have a class that contains many attributes. There is a attribute I want to always be a list, that is it cannot be overwritten with anything else and it will always behave like a list. class ...
0
votes
1answer
47 views

Python Class member access

I am new to python and trying to learn it. Can someone please help me with a simple question I have. I am creating a object as follows: def myList(list): def __repr__(self): return list....
0
votes
4answers
23 views

Find maximum value and its index in a list - Keep getting the wrong index

I'm not sure why am i getting the wrong output. My code: costList = ['$3.38', '$3.25', '$6.00', '$3.50', '$1.50', '$558.45', '$0.50', '$9.50', '$0.48', '$0.85', '$0.65', '$0.26', '$1.65',...
0
votes
0answers
44 views

Keep receiving “System.ArgumentException” when array count is not even

I keep receiving the error: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection When the count of ...
0
votes
1answer
13 views

How to create nested list according to value in the list?

I have 2 lists, that I would like to use to create a nested list: list1=['a','a','b','c','d','d'] list2=['a1','a2','b','c','d1','d2'] result = [['a1','a2'],['b'],['c'],['d1','d2']] meaning that I ...
1
vote
0answers
36 views

Append recursively each record from dictionary to obtain values

Following my question submitted in the last few days, i have a defaultdict which contains in each of the lines a record of the ticket sale for a deviceID, or passenger for a bus sale. The whole ...
-2
votes
2answers
29 views

how to iterate through two lists and not repeat values? [duplicate]

I'm learning python and I've come across this problem that seems very simple, but I can't find a way I have two lists: animals = ['cat', 'dog'] animals_name = ['rex', 'laika'] I tried: for animal ...
0
votes
3answers
38 views

How do I display the key and updated values together obtained from a dictionary?

My code is supposed to remove synonymous words in the dictionary that are 7 or fewer characters long and I will need to display it in key order once I have done all the removing. However, I have no ...
-1
votes
5answers
48 views

How can I convert a list of arrays into one single list? [duplicate]

How can I convert a list of arrays into one single list and print 6 elements per line? the list of arrays looks like this: [['UES9151GS5', 'SQU6245R', 'DEN', 'FRA', '1420564460', '1049\n'], ['...
-6
votes
3answers
63 views

I need to know the number of tuples in a list [on hold]

mensaje = [(42, 10, 4), (479, -100, 5), (70, 1, 7), (65, 500, 1)] I need to know there are 4 tuples in this list if anyone could tell me I'd really appreciate it thanks. If I try with len(mensaje) I ...
1
vote
1answer
47 views

Number items from list according to Set item

I'm using a class to performs my questions... public class Competitor { private final int type; private final String name; private final int power; public Competitor(int type, String name, ...
2
votes
2answers
21 views

How can I assign each varying value of a list to different keys of the same dictionary?

I am trying to create a dictionary(sums), whose keys are the total sum of a list and value is the list itself. This list has a varying number of elements but the same name. Each time the elements of ...
0
votes
0answers
8 views

Select a node in D3.js using a checkbox change opacity

I'm trying to select a node using a checkbox, and change their opacity but it have being impossible. I have try using a conditional. Does I need something else? Like: if (typeFilterList.includes(id)) ...
0
votes
8answers
53 views

Storing coordinates in a nested list using loop

I am having the coordinates of a robot, I am taking the number of robots as input and storing the coordinates in a list called locations. I want locations to store the coordinates of all robots. ...
0
votes
1answer
43 views

passing more than one argument to FUN of lapply

My question builds on a another, similar question: passing several arguments to FUN of lapply (and others *apply) I have a custom function creating a data.frame. The goal is to retrieve a list of ...
-2
votes
1answer
45 views

How do I append coordinates into List

I have the following problem: I need to append coordinates into a list but it wont work. I don't get an error but it isn't appending anything! t1 in my code is a turtle and I want to insert t1.xcor()...
0
votes
1answer
46 views

How to create separate dicts from dicts inside a list? [duplicate]

I have a list containing several dicts. I want to store each of these dicts in a separate variable. The data is something like: my_list = [{'key': 'value'}, {'key' : 'value'}] I have tried the ...
1
vote
8answers
76 views

Python: How do I remove elements from a dictionary and return it as a list?

I have been trying an exercise that requires me to remove words in a dictionary containing words that are 7 or fewer characters long. So far I have tried using the .values() method to get only the ...
0
votes
0answers
44 views

How to handle duplicates in a list but preserving all of them by adding a unique suffix.? [duplicate]

I have a list containing duplicates e.g. l = ["north", "north", "east", "north", "east", "east"] i want the final list to be like this l = ["north1", "north2", "east1", "north3", "east2", "east3"] ...
-3
votes
1answer
31 views

How to lower Count without reducing Capacity in C# List

I have a list that should be completely removed once every frame on an interactive app. I reserved a capacity to 10.000 items at the beginning to avoid the overhead of adding items one by one. Then ...
2
votes
3answers
64 views

Create a list based on list of tuples (value, indices)

I have in input a list of tuples with a string and a list of integers. The integers goes from 1 to n and they appear at most one time: l = [('red', [0,2,5]), ('yellow', [1,4]), ('red', [6])]...
2
votes
3answers
25 views

i used append() in a loop and for some reason the list changes every time not in the way it should

I wrote this code: if __name__ == "__main__" : lst = [] current= [] for i in range(3): print(current) print(lst) lst.append(current) print(lst) ...
0
votes
6answers
49 views

Python: How can I remove square brackets within a dictionary?

I want to obtain values in the dictionary and append it to a list, but I have no clue how to remove the square bracket and so it results in square brackets within another: [['display', 'exhibit', '...
-2
votes
2answers
32 views

How to extract from list and tuples

I query data from database from one colomn and I want use them but I do know how to extract them. [(725696042,), (706284799,), (705263536,), (706705005,)] I what to get the results like this ...
-2
votes
3answers
37 views

How to group dictionaries based on two values?

How to group list of dictionaries as list of unique dictionaries based on multiple key elements? in = [{'location': 'eastus', 'sku': 'S', 'term': 'P1', 'scope': '1'}, {'location': 'india', '...
1
vote
2answers
20 views

DJANGO select FORM that is from a generated list and add an extra default value

I want to have a select drop down form. In this example, i want to have a drop down of all division but it can include one more extra record (which is default=0). How can I generate a list for select ...
0
votes
2answers
50 views

How to overcome foreach loop for list object dynamically

I'm swapping my values in List Object on some conditions and update List Object value. Currently, what I'm doing is - Looping on each object through List - Check If condition is net - Swap values ...
0
votes
4answers
38 views

Converting for-loop into List

i was working on this program: for n in range (0,31): if n%2 is 0: if (n%2)is 0 and (n%5)is 0: print(n) i want the output to be like this, in list. [0,10,20,30] i ...
3
votes
2answers
30 views

Creating a pandas data frame of specific Shape from a list of items

I have a pandas dataframe f a specific size say: ID FACTOR LEVEL 160 SPM P 159 SPM2 S 851 ABS K ...
0
votes
0answers
23 views

How can I add elements of a list using my own function bin_add

I defined my own bin_add function that adds binary numbers. I am having a hard time trying to use that function to add elements of a list I tried using for i in add_list: result = bin_add(i,...
1
vote
2answers
22 views

slicing a python list based on empty strings

I have a python list of this form:list element11 element12 element13 element21 element23 element31 element32 element33 element34... and so on. There is a blank string that occurs after a few ...
3
votes
3answers
35 views

subtraction of lists in python, optimising speed

IN order to find out the substration of two lists in python I use: names_of_files_not_dowloaded = [item for item in total_files if item not in names_of_files_downloaded] It works. the sizes of the ...
3
votes
3answers
69 views

Python: Two lists to be compared for format match and made into a dictionary

I'm using python 3: I have two lists and I want to have them combined in a dictionary using similar information: first_list = [('1234', 'abcd', 'John Doe', 'good_status'), ('1234', '...
0
votes
1answer
31 views

How to format concatenated list output - python

I am using pyexcel to try to filter an excel file for certain values, but I can't figure out how to format my functions output. I need to output cell values in the form [x,y] for pyexcel to read the ...
1
vote
0answers
17 views

How to run to 2 loop simultaneously [duplicate]

I have to loop 2 different loop but I wanna run them 1 by 1 for example: 1st loop 1st instance run then 2nd loop 1st instance run, then 1 loop 2nd instance run then 2nd loop 2nd instance run, then 1 ...
0
votes
1answer
21 views

Problem with the return value from a Future async function

I've created a function that gets a json from an api. The problem is that the function is not returning a value. It returns 'Instance of Future...' I've tried different ways of solving it. If I print ...
0
votes
0answers
15 views

Data Validation Excel Auto Fill List

If i create a list of 3 items. e.g. Green1 Blue2 Yellow3 I rename as 'colours' in the name box. If i go to data validation - allow - list. Then the source as =colours When the list is created i ...
0
votes
0answers
22 views

getting combinations of sub-ists from a list

i have a list of of 53 element each element is a tuple e.g. list = [(1,1) , (2,2) ,(3,3) ,(4,4) ,(5,5) ,(6,6) ,(7,7) ,(8,8) ,(9,9) ,(10 ,10) , ...(53,53)] what i wanna do is to create sub-lists ...