Questions tagged [while-loop]

A while loop is a control structure used in many programming languages to continuously execute a set of instructions as long as a particular condition is met.

0
votes
2answers
19 views

Reading in File line by line w/ Bash

I'm creating a bash script to read a file in line by line, that is formatted later to be organised by name and then date. I cannot see why this code isn't working at this time though no errors show up ...
1
vote
1answer
14 views

Constructing a recursion that forms a chain until no new element can be added

I have a matrix by 9x2 where the first column implies the second column, that is A=[7 10; 1 7; 3 1; 6 9; 10 7; 2 8; 10 8; 10 4; 8 6];I will form an implication chain using these data. Couple ...
0
votes
1answer
42 views

Bash while VERY slow

I have a while loop that that reads in a mail log file and puts it into an array so I'll be able to search through the array and match up/search for a flow. Unfortunately, the while loop is taking a ...
-2
votes
1answer
13 views

Changing for loop to while loop for non-range for loops

for item in lst[0:]:temp1=int(item[1])temp2=int(item[2])Here is a block of code representing the item for each element in the list.How would I change it so it searches through each ...
0
votes
1answer
9 views

I am having issues with a repeating while loop in a switch statement, the loop continues to repeat

I'm a newbie coder and for a class I was required to make a vending machine-like code. However, I used a switch statement as part of it. An issue I faced is that in those if statements I added a check....
0
votes
4answers
55 views

javascript slice within loop for array

I want to take an array output like the following:[a,b,c,d,e,f]and slice it into sections, then output each new array on a newline like this: [a,bc,de,f]Here's what i ...
1
vote
2answers
36 views

Magic square in python

I'm new to coding. I'm trying to program a magic square. A magic square is a square (3 × 3 for my case, could be different), where all rows and columns and diagonals must sum to a certain number (15 ...
0
votes
1answer
12 views

Differences between loops and nested loops in kotlin

fun main(args: Array<String>) {val books=arrayListOf("farenheit 451", "1984", "Altered Carbon", "dark matter", "Le probleme à trois corps")for (book in books) {if (book....
0
votes
1answer
36 views

While loops in kotlin

fun main(args: Array<String>) {var x=9while (x>=0){println(x)x++}}If i compile this code, it will print out an infinite number of iteration of the loop....
-3
votes
0answers
22 views

Generate a txt file, from a given one, with the dates ordered, and these between two dates given with Streams [on hold]

I have a method which receives an input file and two LocalDate dates, and returns another file, with the ordered dates (yyyy / MM / dd) that are between the two given, and these sorted from oldest to ...
-1
votes
1answer
53 views

Perl diamond operator in double while loop hangs

In my Perl script I have a double infinite while loop. I read lines from a file with the diamond operator. But somehow if my script reaches the last line of the file, it does not return undef, but ...
-1
votes
0answers
14 views

How to control a string sentinal value? [duplicate]

I have this code in which I want to check for if the entered id is -1 or not.If it is -1, the loop should exit.System.out.print("Enter item code, -1 to stop: ");String id=in.next(...
-3
votes
0answers
16 views

Convert while loop into for loop

This program counts to a number by a certain fixed interval. Get the number to factor from the user:number=(input('What number shall we count to? '))interval=(input('What interval shall we ...
0
votes
1answer
14 views

Two opposing iterators, list assignment index range error

This code is supposed to reverse the first number items in my_list, while keeping the remainder of the list in its original order.list_copy=[]i=0j=number - 1while i < number or j >=0:...
0
votes
0answers
27 views

Compound Interest with loops [on hold]

Coding Requirements:1. Prompt the user for these required input values: Deposit, Interest Rate Percentage and Number of Months, and Goal. Make sure to select the appropriate data type for each. ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,