All Questions
139 questions
0
votes
1
answer
61
views
how to efficiently check common elements of two lists of different types ( class A and class B) and make a resultant list of type A for all matches
I have a list of class A with 1000 elements that has all unique ids. There is some other Class B , which also has a unique id parameter and this B is a json property of Class A.
the relation is like :
...
-2
votes
2
answers
304
views
Python: best way to iterate through lists and store which has max value for each index
In Python (3.8), I have 15 lists of the same length.
Each list contains floats.
Here for the example, I will pretend I have 3 lists of length 5 to demonstrate my problem:
List1 = [29.561801, 29.564141,...
-1
votes
2
answers
73
views
How to remove elements from list while iterating [duplicate]
hey I have a issue where i want to remove some elements from a list, the problem is it change the index and them don't know how to remove the index that actually need next
so it remove "salt"...
2
votes
3
answers
50
views
Iteratively remove elements of a list based on calculation with adjacent list items Python
I have a list of tuples (representing x-y coordinates), and I want the coordinate to be removed if it is too close to the preceding coordinate (Euclidean distance). If it meets the criteria and is ...
-3
votes
2
answers
93
views
Python3 iterate through a list and print in a certain sequence/combination
I have a list of words I want to iterate through and print a specific order.
For example:
words = ['apple', 'banana', 'orange', 'pear', 'berry']
I want the sequence to be like this:
apple.apple.apple....
0
votes
2
answers
325
views
How do you iterate through a list in Scheme using cond statement?
(define (iterate list)
(cond
((null? list) '())
So far all I have is that it checks if it is a null list. If it is then it passes the empty list. What I am trying to do is I want to iterate ...
0
votes
1
answer
20
views
iterating through list with 2 variables
I have this list:
list=[0, 0.3, .6, .9, 1.2 ,1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
how can you iterate through the list to create values for i and j such as these pairs:
0 / 0.3
0.3 / .6
.6 / .9
to the ...
0
votes
3
answers
332
views
iterate through a list and restart index_1 at 0 if list index is out of range
I am trying to make a program where I have a list my_list_1 = [1,2,3,...] and a second list `my_list_2 = [1,2,3,...] and len(my_list_1) < len(my_list_2). I want to iterate through the lists like ...
0
votes
1
answer
206
views
How do I find the sum of a given list for x[i]≥ a fixed x value, for each x value?
The code block is supposed to do the following:
Find sum(all y_values in the list if the index corresponding to that y value has an x_value which is ≥ a fixed x_value). Find this sum for all x_values ...
2
votes
1
answer
574
views
In Python turtle graphics, color() can't iterate over a list of colors
Starting out with turtle graphics. I wanted to create a program that prints a certain number of squares, at a certain angle apart (number of squares and angles will vary based on user input). The flow ...
-2
votes
2
answers
73
views
Iterating 2 permutation sets
Let's say I start with these two hypothetical lists: color and shape.
I have 15 colors and let's say a recursively infinite number of shapes (like number of sides of a regular ngon). At its most basic ...
0
votes
2
answers
164
views
Can I limit how often an element is randomly chosen from a list?
I am trying to code a match fixture app which takes a certain number of teams and puts them vs each other without repeating the same team twice successively i.e having the same team play twice in two ...
1
vote
1
answer
34
views
Want To find a particular number in a list , True/False. Loop isn't iterating. Can someone explain why
x = [1,9,9,9,9,2,3,4,5,6,7]
def consec_123(nums):
for i in range(0, len(nums)):
if nums[i] == 2:
return True
else:
return False
pass
#The result comes out ...
3
votes
4
answers
2k
views
Iterating through list of lists of lists
I am trying to iterate through a 3-D list in python(not numpy but I am willing to convert to a numpy array if this makes it easier) in such a way that from a list like this:
a = [[[0, 0], [3, 0]], [[1,...
1
vote
0
answers
10
views
How to repeatedly insert arguments from a list into a function until the list is empty?
Using R, I am working with simulating the outcome from an experiment where participants choose between two options (A or B) defined by their outcomes (x) and probabilities of winning the outcome (p). ...