All Questions
Tagged with conditional-statements for-loop
456 questions
0
votes
1
answer
88
views
How can I define an infinite loop condition in the for loop in java?
I was making a program in which user can keep entering numbers till user enters a multiple of 10. So I wanted to created a for loop for that and didn't knew what should be the infinite loop condition ...
0
votes
0
answers
44
views
problems validating form with a loop for python
I am trying to validate my fields in a more efficient way and I think I am on the right track, but I have a problem with the for loop, the code is as follows
First of all I manage all the fields ...
1
vote
2
answers
62
views
My code for conditional sum in vba is showing error
Dim wb As Workbook
Dim ws As Worksheet 'for looping worksheets
Dim i As Double
Dim lastrowG As Long
Dim lastrow As Double
Set wb = ThisWorkbook
For Each ws In ThisWorkbook....
0
votes
0
answers
57
views
Python - Priority-Based Conditional Data Transformation
I have a use case of a form with 3 dropdowns ( A, B and C for this example). They each have 4 options:
Which gives me data per record/ID like this:
data = {
'ID': [1, 2, 3, 4],
'A_OLD': ['A1',...
1
vote
3
answers
56
views
For every instance if "A" in Column1, create a new column with all values associated with "A" from Column2
Here is an example data frame:
df <- data.frame(Key = c(rep("A", 2), rep("B", 4), rep("C", 3), rep("D", 2)),
DataID = round(runif(11, min = ...
-4
votes
1
answer
53
views
Loop problem using For and the conditional if in by JavaScript [closed]
I built a function in JavaScript called oddNumbers which I used a for loop and if condition in order to print the odd numbers between 0 to 10. However, the console printed only "Odd: 1".
I ...
0
votes
2
answers
76
views
For loop condition not working as per expectations
I am writing a code in this code I have to find the minimum steps which can take me from index 0 to index n-1. nums[i] represent the maximum jump I can take from ith index. (Reference leetcode Q45 ...
0
votes
1
answer
74
views
Why is this part of my for loop not working?
I have this for loop in my code which uses an array filled with randomly generated numbers which is as follow
for (int i = 0; EndResult == true; i++) {
count = count + 1;
if (count == ...
0
votes
1
answer
38
views
"Object Required" Object or Range Reference for vba With For loop
I'm using vba to evaluate 2 columns and either populate text, or color change based on comparison between 2 dates. Seems like this should be easy.
I'm not super proficient in VBA, so I'm struggling ...
0
votes
1
answer
73
views
trying to create an isogram using javascript (but there's something i don't understand)
so i'm fairly new to coding and i'm trying to make an isogram using javascript (without using any built-in methods because i'm still learning the basics) but i'm having difficulty grasping the logic ...
1
vote
1
answer
83
views
Looping through the rows of a dataframe to create a cumulative sum
library(tidyverse)
set.seed(1)
start <- mdy("01/01/2022")
end <- start + as.difftime(99, units = "days")
days <- seq(from = start, to = end, by = 1)
days <- sample(days,...
0
votes
2
answers
65
views
Looping over first two indices in 4-Dimensional Array?
I have an np.array that has dimensions 478,533,3,3 (variable is titled "window," generated with NumPy stride tricks sliding window from a larger 2D array). The 478x535 portion of the array ...
0
votes
2
answers
74
views
Fill values into column of data frame based on two conditions
I have a dataframe where I would like to fill in values from column "reference column" into the column "trial_number" based on the following two conditions:
condition 1: value ...
0
votes
3
answers
63
views
How to cleanly iterate over a list of lists to get cumulative totals conditional to another list in python?
Consider the following code:
list_of_lists = [[1, 1], [2, 2], [3, 3],[4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]] # a lot longer than this in reality
list_of_dicts =[{'vol': 3, 'key': 0},{'vol': 5,...
1
vote
2
answers
53
views
iterate an object and pass any keys of a specific value to an array
I am trying to get specific keys of a certain value within an object into an array. When I specify the value the array is filled with all keys not just the ones that match the value. I only want the ...