Newest 'list' Questions - Stack Overflow

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.

0
votes
2answers
32 views

Join 2 collection list together from 2 data sources find the matches and loop through the results

I am wanting to merge together 2 different collections. Example collection 1: (linqpad to live sql server) Sample Data (collection azedIdentity): PersonID | FirstName | LastName | 3197908 ...
1
vote
1answer
28 views

Right way to combine group of collections

I have done some code to combine in parallel group of collections which contains pairs[String,Integer], Example Thread 1 [Car,1][Bear,1][Car,1] Thread 2 [River,1][Car,1][River,1] Result should be ...
0
votes
2answers
29 views

Question about accessing indices in nested lists

I was learning about Deep Learning in Kaggle through an exercise and this confused me. In order to write a code for checking whether something was a hot dog or not, there was a list of predictions, ...
0
votes
3answers
32 views

How to take a number out of a list and put on another list? (python)

I have some code that creates a list with numbers, from 1 to 561. I want to create a variable that is called "ultimate" that has 45 of those values, but, the ones that I put on that list, I want it to ...
0
votes
1answer
34 views

Creating heap algorithm to output a list of all permutations, in base python without other modules

I am trying to build an algorithm which will output a list of all permutations of an inputted string and I am getting very lost, especially when it comes to heap algorithm. I tried to copy the code ...
-1
votes
0answers
20 views

python index error: list index out of range- [on hold]

i have been trying to run this code but it keeps on giving the error 'list index out of range'.i read some other questions and added len(a) but it gave 'int' object not iterable. while i<n: ...
0
votes
2answers
19 views

deleting doubled measuring points and adding missing one

I want to delete doubled time values including their assigned measurement values and fill the missing time values inbetween. I'm working with some simulation data. Basically I have lists in the ...
0
votes
1answer
28 views

how to store multiple values kind of output generated from for loop in a list in python?

I was printing output in an iteration using a for loop in the following format. print(fname, "[", line_no, ",", index, "] ", line, sep="") But, for some reason, Now I have to print the whole output ...
2
votes
2answers
31 views

Split the list by every 4th element if 5th element is “Name” or split by 5th element if 5th element is Address

I have a 8000 list of names, company, address1, address2, address3(optional) ina sequence order as shown below. This is a python list [John It Tech 1243 mary drive florida-32006 mark Infotech 1245 ...
0
votes
0answers
17 views

Sorting Python objects by their date attribute - why is my code not working? [duplicate]

I am new to Python and programming in general and currently working on my first "big" project as a means to further my learning beyond reading books but also to develop something I will be able to use ...
1
vote
2answers
34 views

for loop, split string, save parts of string to new list, IndexError: list index out of range - works for one part of string and not the other

New to python. I have a list of filenames that I split apart in a for loop. I want to take a few of those columns and put them in a new list. It works for x[0] but not for x[6]. When I print x[0] and ...
-2
votes
0answers
10 views

how to make my code output the average of the array “answer”?

I have a code that keeps collecting numbers into a list called "asnwer" and callculates the average when the input is "p". Unfortuanty; it doesn't work. Can anyone please provide some feedback and ...
-4
votes
0answers
76 views

How to single out element from a list?

I have a list. List<double> list = new List<double>() { alist[a] }; If i try to find closest number in the list from a number variable, the code sort out the entire list, like if it was ...
2
votes
1answer
33 views

Partitioning a String into more pieces with separating char in Haskell

I have the following homework: Define a function split :: Char -> String -> [String] that splits a string, which consists of substrings separated by a separator, into a list of strings. Examples: ...
1
vote
5answers
45 views

Is there any way to write with less “nesting”?

The problem is a homework problem. I think I solved it but I'm wondering is it the best solution? The problem is to take a list and run through it to see if it contains a specific subsequence: 007. ...
0
votes
3answers
34 views

Dig through a list with list using a for function

In a function I am making, I have a for x in range(y) loop that will create a list with x list depth inside it. For example at x=1, it will create [[a,b],[a,b]] and at x=2, it will create [[[a,b],[a,...
0
votes
1answer
27 views

How to access data from a post response in JSON format

I am trying to access a dictionary that has been returned after making a post to an API, but I am having difficulty formatting the data with JSON. It seems to be returning the data as a dictionary ...
2
votes
2answers
23 views

How do I create a list of columns which contain specified strings in their rows?

I have a dataframe which has hundreds of columns, I want to return a set of the columns that contain only true/false strings. i.e. a b c d e true false 34 cat true false false 16 dog ...
0
votes
0answers
14 views

How to bind two files according to list name elements?

I have two files, one created with R which is a list which several items which looks like this : $`1` [1] "UniRef90_A0A076JUS5" "UniRef90_A0A076JUV9" [4] "UniRef90_A0A076JUX2" "...
0
votes
4answers
36 views

Pythonic way of accepting single number or list and use it as a list (equivalent to numpy.atleast_1d() )

I have a function which accepts single numbers (e.g. int or float), but also a list like structure. This argument will always be further processed as a list. What would be the pythonic way of ...
0
votes
3answers
21 views

Keep Elements of a dictionary rather than pop?

l = {'apple': [0, 4], 'orange': [3], 'beer': [9], 'rice': [6], 'melon': [10, 11]} How do I retain only {apple: [0,4], melon:[10,11]} I know the lengths of these are 2.
-1
votes
1answer
54 views

Optimise a minimum operation on a python list of list

I have a list of list where each list corresponds to the boundary point of a figure. I have to extract a list of four points, each defining the enclosing rectangle of the figures. For example, I have ...
1
vote
1answer
17 views

Getting a list of all project owners from GCP

I am trying to get a list of all GCP projects on the domain and the project owners and export it to a CSV so I can throw it into a google sheet. Getting a list is simple enough, but I can't find a way ...
0
votes
2answers
20 views

I am trying to use a for-loop to insert an element of one list to the first element of each list within a list of lists

So I am writing a program to automate a budget. I am trying to account for expenses in the newest data that has not previously been part of the budget. The idea is to create a list that stores the ...
0
votes
0answers
16 views

How do i display a (listof (listof Nat)) containing the first n rows of Pascals triangle [duplicate]

This is the question which I am trying to solve Write a function (pascal n) that returns a (listof (listof Nat)) containing the first n rows of Pascals triangle. (That is, the rows from 0 to n−1.) I ...
1
vote
0answers
34 views

How can I select a different value in a column that contains a sublist in each iteration in python?

I have a data frame that has a column which contains lists in some rows. I would like to return a different value of those lists in each iteration. In my main function I iterate row per row of the ...
0
votes
0answers
22 views

ITextSharp not converting ordered lists correctly

I'm using ITextSharp to make pdf files and the problem is when I try to make ITextSharp convert my html text to pdf it comes out wrong. I want to know if it is possible to print the ol lists as they ...
1
vote
2answers
25 views

same code is giving different output when used in main function and in user defined function even when the input is same

so, the question says, we have to sort an array using insertion sort algorithm and print the resulting array after each iteration with numbers separated by space. please help me understand what is the ...
2
votes
1answer
43 views

Comparing a string with elements in a list

I'm trying to code a password strength checker, and I want to deduct points if the entered password is a common keyboard combination such as "qwerty" or "asdfg". I have a list that goes ['q', 'w', 'e',...
0
votes
4answers
34 views

categorize sentence based on words in sentence for multiple sentences

data = ["my web portal is not working","online is better than offline", "i like going to pharmacy shop for medicines"] words = ["web", "online"] I want to iterate over sentences and check if any of ...
0
votes
0answers
9 views

how to get generic List from storeprocedure by using entityframework

I have a methods that's return List record in entity framework by using store procedure.but i need to return generic List. for example when i pass different-different model and store procedure it ...
0
votes
1answer
19 views

How to modify an existing dictionary in ansible?

I'm trying to add an existing list to an existing dict in Ansible. I have a dict "jbossvars" containing the following (ansible debug) "jbossvars": { "environments": { "TEST_ENV": { ...
4
votes
9answers
72 views

How can I multiply elements in one list while providing a range in another

I have two lists that I will later use do determine on how many pages of a document I'm looking at. The first list (l_name) contains the name of the document. The second list (l_depth) contains the ...
0
votes
0answers
45 views

How can I store columns of a text in an array with which I can then make calculations?

community, I am currently stuck on a homework assignment which requires me to read a text file and then make further calculations with it, my questions are now. How do I read a text file and store the ...
4
votes
1answer
107 views

Decrementing iterator after each loop iteration shows weird behavior

I created a program to try to practice on the semantics of the list data structure. I noticed a weird difference in the following pieces of code: First code: #include<iostream> #include<...
1
vote
2answers
36 views

Multiply every element in a nested list by a constant

I have been reading a lot of similar posts here, here, here, and so on, yet I cannot solve my problem. I have a list of list of pairs like this: my_list = [[[0, 3], [0, 0]], [[77, 94], [76, 94], [77,...
0
votes
2answers
37 views

In DrRacket how do i alter my program that uses if statements to rather use a conditional statement

Here is the question I am trying to solve Write a function (last-substring-len s n). It consumes a Str and a Nat, and returns the substring of s with length n that comes last alphabetically....
0
votes
0answers
21 views

Early reference to row of a csv file imported as list break my read dataset?

I am opening, reading and storing into a list data structure the content of a csv file (https://www.kaggle.com/ramamet4/app-store-apple-data-set-10k-apps). I tried to store header and rest of the ...
-1
votes
0answers
11 views

Split the list by every nth dynamic value and N changes on a condition

I have a list of strings as below -Name -company -addr1 -addr2 -addr3 -Name -Company -Add1 -add2 -Name I want this list to be split based on availability of addr3. I want to check the ...
-5
votes
5answers
77 views

Creating an algorithm to solve a problem in python

Algorithm Objective: link to the pictures i took while giving the amazon interview: [https://boards.wetransfer.com/board/shl7w5z1e62os7nwv20190618224258/latest][pictures] Eight houses, represented ...
0
votes
1answer
23 views

How to pass list of conditions to method which checks all posibble combination of conditions?

I have pandas data frame, and list of conditions: import pandas as pd inp = [{'c1':10, 'c2':100, 'c3':120}, {'c1':11,'c2':110,'c3':120}, {'c1':12,'c2':120, 'c3':25}] df = pd.DataFrame(inp) filter1 = ...
-2
votes
2answers
27 views

Modify list by copy specific item in the list [on hold]

I want to modify the list using python. My list is [1,'','',2,'','']. The target output should be like [1,1,1,2,2,2]. Just copy the values to the ''s.It should be a simple loop problem but I couldn't ...
0
votes
1answer
14 views

Pass list of subclass objects to a method which has list of superclass as a parameter [duplicate]

According to my use-case, I have a class myClass implementing an interface myInterface. public class MyClass implementing MyInterface{ ... } I have got a method which has List as parameter. ...
0
votes
1answer
39 views

How to get list out of list in python? [duplicate]

Is there any way to remove double list? Right now I have a list inside a list as an output. target_rule = [ '2.1.1 Context','2.1.2.4 Helping Us out','We know that'] target=[] x=[s for s in ...
0
votes
1answer
25 views

List not being overwritten in expected manner

I am new to Python. What my code is supposed to do is check the line against an existing list, if the line is not already in the location file it asks for the user to assign a value to it and updates ...
0
votes
3answers
38 views

How can I select elements in a column based on a priority list in python?

I have a column that contains multiple values in each row. I am trying to write a function to select just one value of each row based on a priority list, so that is reduced just to one value. I am ...
2
votes
3answers
45 views

Linked list add new root element

I'm trying to add a new root element to my linked list. I already know the correct answer but I dont understand why there's a double pointer to the current root element. Here's the correct code: ...
1
vote
2answers
54 views

Algorithm to convert a list of paired equivalent values into lists of all equivalent values?

I am working on a program that needs to be able to remove duplicate values from a list of lists. However, I can only identify the duplicate values by a pairwise comparison. When I am done with the ...
-1
votes
4answers
39 views

Printing a URL if it has a certain keyword

I have function which extracts the urls from espn. the urls looks like this http://www.espncricinfo.com/series/13224/scorecard/426406/scotland-vs-england-only-odi-england-in-scotland-odi-match-2010, ...
0
votes
1answer
46 views

Is it good practice to create a class holding a list of objects (i.e., pointers) that will be used in a list as well? [on hold]

Step one, I create a class that holds a list of objects. It doesn't hold the objects themselves, just their pointers references. The object is not creating the objects. Step two, I create a list of ...