Questions tagged [loops]

Loops are a type of control flow structure in programming in which a series of statements may be executed repeatedly until some condition is met.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
34 views

what do i need to modify in the code to make my desired output?

A B C D E D C B A A B C D D C B A A B C C B A A B B A A A make this pattern using the code below: n = int(input('\nEnter the No. of rows : ')) n=n//2+...
Harshul Kala's user avatar
0 votes
2 answers
23 views

subtract from previous row by current sas

I am dealing with a repayment schedule and have something along the following format I need to calculate the last row new_outstanding in sas? by removing the amount outstanding from the previous row I ...
John Seb's user avatar
1 vote
1 answer
29 views

Splitting Mismatched Rows into Multiple Rows in a Pandas DataFrame

I would like to split the mismatched values within each column into separate rows while preserving the values in the 'Gene.ID' column for the new rows. import pandas as pd data = { 'Gene.ID': ['...
Umar's user avatar
  • 129
0 votes
1 answer
35 views

SAS macro that loops over vectors instead of variables

I have a few lists, something like TeamA = (Tim, Sally, Anne) TeamB = (Jake, Lucy, Lily) TeamC= (Andy, Luke, Tom). There are 20 teams. I would like to do %let team1 = TeamA TeamB TeamD TeamH TeamA ...
TierTe's user avatar
  • 5
5 votes
1 answer
89 views

Under what circumstances is `vapply()` slower than `sapply()`?

The documentation for the *apply() functions states: vapply is similar to sapply, but has a pre-specified type of return value, so it can be safer (and sometimes faster) to use. [Emphasis mine.] It ...
Mark's user avatar
  • 9,352
0 votes
1 answer
42 views

sum a column between two searched values

SUM "B" column between two searched values in "A" column THEN LOOP through several hundred rows later in a seperate piece of code I will SUM groups of SUMMED columns [![flow ...
jamesrnz's user avatar
1 vote
2 answers
41 views

how can I store inputted data asked for in a loop to a separate list each iteration?

I'm writing a program that asks the user for a number of teams between 2 and 10, and then takes a team name and names of players on that team till the user enters done. it then moves onto the next ...
alex's user avatar
  • 13
-2 votes
1 answer
31 views

Task A: write programs to read a sequence of integers and print the smallest and largest of the inputs in java using while loop and explain each step [closed]

Task02: Problem E6.2 a,b,c,d from the Book. (Listed as E6.2 in the images at the end of this document). Create a class called InputAnalyzer. Use the following method names for each part of the ...
Tina386's user avatar
0 votes
0 answers
12 views

Using a Scanner object in a while loop for a menu gives a NoSuchElementException [duplicate]

I'm creating a simple main menu for my program which asks for users to input an integer between 1 and 6, does the corresponding option using a switch statement and then should loop back to the main ...
Gyro's user avatar
  • 13
0 votes
1 answer
23 views

python 'int' object is not iterable. Please

Code: liste10=[1,[2,3],[4,5,6,7]] for i in liste10: for x in i: print(i) Error: --------------------------------------------------------------------------- TypeError ...
Batuhan Koyuncu's user avatar
-1 votes
2 answers
29 views

Find the sum of all odd numbers between a and b (inclusive), where both a and b are user inputs

I keep getting a compiler error in this section: public class LoopsComputer { public static void main(String [] args){ computeEvenSum(); computeSquareSum(); printPowers(); oddSum(...
Tina386's user avatar
0 votes
0 answers
5 views

Create a moving 30 year climatology varying from 5 to 5 years

I need to create this climatology with this data on the site: https://www.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/detrend.nino34.ascii.txt However, I don't know how to do what I want ...
Beatriz Ferraz's user avatar
-1 votes
0 answers
17 views

While loop doesn't stop when condition is false [duplicate]

I made a looping code where it loops when error > xtol but when the error = xtol it doesn't stop, it only stops when error < xtol, any suggestions on how to fix this?enter image description here ...
Lyn's user avatar
  • 1
-2 votes
1 answer
16 views

Web Scrapping issues while getting links [closed]

So, I'm doing a project where I have to get some csv files from an specific website. The issue is that I'm not getting all the links. I've done the process one by one (until the 3th-one), but when I ...
Angel Panda's user avatar
-1 votes
1 answer
44 views

How do make this C# program keep looping until the user has entered an integer?

I want the program to keep asking the user to put in a number until they finally use the correct data type, instead of just exiting the program. This is what I have written. using System; using ...
valeria's user avatar
-3 votes
2 answers
54 views

how do i create pattern that goes like + and then in the next line -+ and then next line +-+? [closed]

i used n = 5 for i in range (n) : for j in range (i+1) : print("+" , end="") print() but the code print +- in the line 1, but I want to print + then -+ then +-+ please give ...
Reynaldy Al's user avatar
-1 votes
0 answers
23 views

Type conversion in Python with bool() in a loop or conditional statement [duplicate]

While programming a little webserver in python I came across this statement: message = connectionSocket.recv(1024) if not message: connectionSocket.close() continue Obviously the variable ...
auriga's user avatar
  • 1
0 votes
0 answers
16 views

Unable to use global variable with createElement inside loop [duplicate]

I am unable to create a global variable for a document.createElement('br') object and reuse it inside loops. In the example, I show where can: Example 0: Call document.createElement('br') each time ...
Adam Sassano's user avatar
-3 votes
1 answer
25 views

the array and loop program in c is working on one test case but not working on the other one

The software tool is a repository of files, often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, ...
Short's user avatar
  • 1
0 votes
1 answer
12 views

Nextjs ReactServerComponentsError:

im new to nextjs this is the first app building using Nextjs i tried to add FAQ.js page but it fails here is my code: // ./src/app/services/Faq.js import React,{useState} from 'react'; const FAQ = () ...
Hazal Kaya's user avatar
1 vote
2 answers
45 views

How do I construct an "If loop" inside of a for loop for rows and columns?

I have a data frame in R which has measurements of fold change (fc) and columns which are fc_0.1, fc_0.2 etc. until fc_2. I am attempting to populate every row in each column with a 1 if it equals or ...
Max's user avatar
  • 13
0 votes
0 answers
11 views

Google Maps Nearby Search API pulling loop returns unwanted elements

I am very new to python and I'm trying to make a loop to pull Google Nearby Search data (I know, a very ambitious project for a noob). I've written a code loop based on my understanding and several ...
Rhinosaur's user avatar
-2 votes
0 answers
28 views

Python Multi user quiz [closed]

I am trying to create quiz game for multi users where it would shows in the end which user got highest score and what is the total average score of the users, I got everything else working however I ...
justmohsin's user avatar
-2 votes
0 answers
19 views

why does this function run with an undefined parameter? [duplicate]

why does this run with the function parameter "todo"(no s) even though the array is called "todos" and not "todo"? programming languages don't understand plurals so "...
Lexi 's user avatar
-1 votes
2 answers
52 views

Loop used to execute a procedure multiple times fails during nth run

I have the following code running a loop DECLARE @table_name NVARCHAR(100) , @sql NVARCHAR(MAX) , @sp_name NVARCHAR(100) , @rep_dt nvarchar(10) , @min_rep_dt DATE DECLARE mycursor CURSOR LOCAL STATIC ...
Chezza's user avatar
  • 19
0 votes
1 answer
17 views

Ansible remote copy loop with scp -3

I'm trying to create a playbook that copies a directory from remote_host1 to remote_host2, using scp -3p command, where remote_host1 name is created by interpolating some fixed string with a variable ...
Lucio Crusca's user avatar
  • 1,307
0 votes
1 answer
49 views

Loop backwards won't loop and find variable

I have tried several thing with different types of looping lastrow -1 , I have done it forwards no problem..Backwards fails to do loop or find.Empty row on found variable which creates empty row above ...
jamesrnz's user avatar
-2 votes
1 answer
29 views

How to loop through a list of variables to pass into stored procedure parameters in T-SQL [closed]

I have a stored procedure that takes in two parameters: a beginning and an end date in the format YYYYMM. The format of this field (in the underlying table is simply int). The stored procedure ...
Shaye's user avatar
  • 195
-3 votes
0 answers
28 views

make a shape use a for-loop in javascript [duplicate]

how to make this with for-looping console I tried like this` let row = '' for(i = 5; i > 0; i--) { for(j = 4; j <= i; j--) { row += '*' } row+= '\n' } console.log(row) ...
hens's user avatar
  • 1
-3 votes
3 answers
54 views

Create a function which returns the number of true values there are in an array

The code compiles but always returns 0. When I read the code out it makes sense that it should work; I've spent a while troubleshooting, not sure why it isn't working. public class Challenge { ...
Jack M's user avatar
  • 37
-1 votes
0 answers
23 views

Create subnet based on defined structure in loop

I have prepared a structure like the one below, which can include different subnets and configurations. I am attempting to create subnets based on this structure, but I keep encountering errors. how ...
Korman's user avatar
  • 7
0 votes
1 answer
68 views

C question solved but cannot pass the test system(timeout)

I'm a beginner in C and I've been working on my homework but I'm having trouble solving the problem Here's the problem: Given the lower bound N (in pyeong) of the size of a house, and the set of ...
archlotteatir's user avatar
-3 votes
0 answers
43 views

Why does my python socket code only run for 1 loop?

I have this code in server.py: import socket import threading import time import json import yaml import logging # Constants SERVER_IP = '0.0.0.0' SERVER_PORT = 12345 ITEMS_YAML_FILE = 'items.yml' ...
Mrmii321's user avatar
0 votes
2 answers
25 views

Equipment Log Google Sheets - fixing while/for loop in Google Apps Script for check in/check out based on checkbox

I am trying to create a script on google sheets where when I click a checkbox, another sheet is updated with a new row with a log of that click. My issue right now: I'm trying to get it so that when ...
programmerInTraining04's user avatar
0 votes
0 answers
22 views

MonYear looping with variables to accumulate totals for 2 variables

I have currently managed to obtain from startdate and enddate a loop to include all variables by formatting the date and running the following; First step data loandata2; set loandata1; date = ...
John Seb's user avatar
0 votes
2 answers
54 views

How to optimize memory and speed for repeated survey-simulations in R?

I am attempting to conduct a simulation in which I have 257 sub-distrct and a list of villages within each sub-district, each with a known percentage of people that have a certain condition. I want to ...
Lewkrr's user avatar
  • 418
0 votes
2 answers
28 views

Why is my code giving a value error that the list index is out of range?

inp_list=[10,1,11,1,29,876,768,10,11,1,92,29,876] for i in range(len(inp_list)): for j in range(i+1, len(inp_list)): if (inp_list[i]==inp_list[j]): inp_list.remove(inp_list[i])...
Taniya Pal's user avatar
1 vote
3 answers
81 views

function inside C loop condition

I can have something like: for (unsigned i = 0; i < get_length(object); ++i) { ... } where I know for sure that get_length(object) will not change during the loop lifetime, or I can convert it ...
Sasha's user avatar
  • 215
-2 votes
0 answers
22 views

SSH into list of servers and if one server doesn't connect continue in Python

i have a list of server and i have to regularly check if an specific app is installed on the server or not and if not then install it, and i wrote this code but if one servers is not available or can ...
Jamie Karvan's user avatar
1 vote
1 answer
59 views

Oracle query to list all occurrences of a string and its subsequent values from CLOB field

I have a CLOB field in my Oracle table and would like to extract all occurrences of the string that matches the pattern 'RES_GetResData_Public_ScreenPrint' and its subsequent values (which are ...
AR91's user avatar
  • 15
0 votes
0 answers
48 views

Creating a PowerShell Function to calculate average rates

I'm working on a project, and I'm stumped, so I'm turning to you guys for a little help. What I need to do is Create a function with the required filename parameter, which I have done already, and ...
Jeremy Frank's user avatar
0 votes
1 answer
55 views

Oracle query to list all occurrences of a string from CLOB field

I have a CLOB field in my Oracle table and would like to extract all occurrences of the string which matches the pattern 'RES_GetResData_Public_ScreenPrint'. **Example - ** |...
AR91's user avatar
  • 15
0 votes
0 answers
41 views

How do I use pandas to make pairing of rows based on values from multiple columns and update counts for pairings?

I have a data frame that looks like this. In this table, I am trying to make pairings using following logic: Subcomponents A, B, C, D make 1 parent component which is Y and subcomponents E,F,G,H make ...
fault_final's user avatar
-1 votes
1 answer
26 views

Looping through a table to send emails

I'm trying to figure out how to loop through a table and execute and email once a field changes. So, in the table, I have the following... Name Num Flag ID Email A12 1 A 42 ...
Ashley's user avatar
  • 9
0 votes
2 answers
44 views

Python Pandas For Loop with If/then condition

I have the following dataset which I'm looking at banking approval data by two different date months (EOM Date = is when it was uploaded & Approve Date = When facility was actually approved). df = ...
svenvuko's user avatar
0 votes
1 answer
31 views

display 3 div in columns, then 1 div, using a loop

I would like to have 3 div in a row, then , when I click on one of them, a div which will take 100% of those 3 rows will be display under it. html <div className={styles.features_type}> ...
Celine's user avatar
  • 1
0 votes
1 answer
37 views

Looping through tables and querying each of them in two different schemas

I have a script that I run for a particular table to compare, for now just a simple COUNT(*) on two different schemas (doing a migration). Here's what it looks like: SET table_name = 'users'; SET ...
Moseleyi's user avatar
  • 2,603
0 votes
2 answers
72 views

Infinity loop with async function [closed]

I need to fetch data from server in infinity loop. This code generates a reursion, is this correct way? My code (code updated): function pause(delay) { return new Promise(r => setTimeout(r, delay)) ...
Bener Beer's user avatar
1 vote
2 answers
74 views

Is there any special case in c loops (while loop) where we must use increment operator before the variable instead of after?? example: ++n against n++

Okay, I'm learning while and for loops in C so i was trying to write a code that prints 1=0 with the initialization expression as count = 1, test expression as count < 5 and update expression as ...
Marvelous Dele's user avatar
-2 votes
2 answers
74 views

How to constantly generate random numbers inside for i in range loop

import random world_size=8 for i in range(world_size) chunk_type=random.randint(1,2) print(chunk_type) import random class chunk_type(): chunk_type=random.randint(1,2) world_size=8 ...
Op Gaming's user avatar

1
2 3 4 5
1919