Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
0 answers
35 views

Can anybody explain me how to make "while" with empty body look better? I know that I can do this a different way, but I am really interested in the ways of implementing "while" ...
3 votes
2 answers
71 views

I'm trying to find the outbreak time (when the number of zombies >= number of humans) as a function of the zombification rate gamma, using the following code: arrOutbreakT = [] arrGamma = np....
me1ll0's user avatar
  • 33
-3 votes
1 answer
121 views

I want to write a code that finds the derivative to any function and want to take a user input on what type of function they're inputting is. Essentially I tried to write a while loop that only accept ...
Uzair Hafesji's user avatar
-2 votes
2 answers
132 views

it's not breaking and I don't know why This is the problem section of the code. It is working fine, the try except is fine, and the check if not in range's break is working fine. But not the second ...
Sheep Doom's user avatar
0 votes
2 answers
99 views

I have searched everywhere but could not find a solution hence posting here. Partclone prints the status / progress on the same line and it keeps updating this line, I want the progress to be ...
user2107349's user avatar
3 votes
1 answer
97 views

I am trying to re-run a nested for loop within a while loop if the while condition is not met. If the condition is met then I want the inner loop to terminate and proceed to the next iteration of the ...
user3500717's user avatar
3 votes
3 answers
220 views

I want this program to first ask user to start or exit which works fine: #include <stdio.h> int main() { int ask; char ask2; char clip[100]; printf("1.start\n2.exit\n&...
Aadil's user avatar
  • 31
1 vote
2 answers
88 views

I'm reformatting a big file with sample metadata. I have a file (let's call it File2) with the group each sample belong to, with one id and pop per line. My idea was to while read over that file and ...
Pedro Morell's user avatar
2 votes
1 answer
150 views

I'm a beginner programmer learning C as a hobby. I just learned about accepting user input using scanf() and thought it would be a fun learning experience to make a small "game" that runs in ...
gus's user avatar
  • 23
-9 votes
1 answer
151 views

I was trying to get the last word of the sentence using the .find() method in a loop. My code: sentence = "please write a program which keeps asking the user for words" index = 0 substring = ...
krish mundra's user avatar
0 votes
2 answers
167 views

I have this homework program to calculate mpg. The -1 is the sentinel value which is supposed to skip the questions asking the user for gas and miles when inputted. At the moment, the program ...
Smallintestine8's user avatar
0 votes
1 answer
160 views

I am using Nginx + Lua (OpenResty, LuaJIT), and I did some performance tests on various loops. local ngx_log = ngx.log -- https://openresty-reference.readthedocs.io/en/latest/Lua_Nginx_API/#nginx-log-...
C0nw0nk's user avatar
  • 992
0 votes
0 answers
83 views

I've been building a promo-doro timer using the indicatif library, but I notice that the ETA provided by indicatif does not work properly when running the timer logic manually. The timer always starts ...
Nolan's user avatar
  • 23
-4 votes
4 answers
180 views

Task: to make console to display a message "Happy birthday!". Number of messages equals the number which user inputs to console. Condition: program should break the cycle, when number of ...
Uroboros First's user avatar
3 votes
1 answer
96 views

I am working on a simple 2 player dice rolling game and have found a problem that i haven't been able to fix, after a While loop, it refuses to execute an if statement def Main(): global player1_score,...
user30428193's user avatar
1 vote
2 answers
118 views

I have constructed a for loop that I though would given me a "circular" index that starts at some number (n) and cycles around again to that number through the series 0 to n, that is "...
Anne Eve's user avatar
-1 votes
2 answers
107 views

While, "strong_beat.play()" is in the while loop, it stops running *import simpleaudio, time, math temp = 0 strong_beat = simpleaudio.WaveObject.from_wave_file('metronome2.wav') while temp&...
DarkMud OfHorror's user avatar
2 votes
3 answers
166 views

I have a function called escape that copies over a character array into a new one while replacing the \t and \n characters with raw characters \t and \n i.e single character '\n' becomes 2 characters '...
saberton's user avatar
0 votes
2 answers
80 views

Is it possible to save a value on different variable in a while loop? For example this is my code category = [] #differs depending on the input of user var1 = [] var2 = [] var3 = [] i = [] max_count =...
Rodel Silvano's user avatar
-1 votes
2 answers
100 views

I face the following problem, which looks like a bug (or maybe am I the bug): I have a loop: #!/bin/bash # TARGET=/sd/REMOTE_BACKUP LOGDIR=/sd DEBUG=: # Init daily information (reset on each run and ...
Alan's user avatar
  • 7
2 votes
1 answer
93 views

I thought my script worked in test environment (it prompted me for credentials again and again when I mistyped, but accepted them after I typed them correctly). But when I tried to use it in ...
skysthelimit91's user avatar
0 votes
6 answers
238 views

I need to create a program that can do this: Input: args2 one two three Output: You have entered 3 arguments: #1: one #2: two #3: three This is what I have so far: #!/bin/bash echo "You have ...
waterscapes's user avatar
0 votes
1 answer
112 views

I have the following bash script which works fine but only goes through the for loop once! #!/bin/bash csv_file="regime.csv" ratio=(0.2 0.4 0.6 0.8) while IFS=',' read -r col1 col2 col3 ...
Karen Tabar's user avatar
0 votes
2 answers
157 views

The code is supposed to reverse the words that have the length equal to longest word length from the phrase. Input string: #Voi#da#bacu#la#info# Expected output string: #Voi#da#ucab#la#ofni# I ...
Mihai's user avatar
  • 9
0 votes
1 answer
85 views

I'm having a bit of a challenge. I have a table with input fields and some data that i fetch from the DB in a while loop. Now I want to calculate the sum of input1 * input2(value=10) and show it in ...
Brutus's user avatar
  • 9
1 vote
1 answer
187 views

I am a novice to programming, and I'm doing it for fun. I encountered a strange bug I do not understand while trying to parse simple user input. My problem is that when an invalid character is read (...
violetRM's user avatar
1 vote
0 answers
29 views

I'm creating a multiplication game and am suck on two things. I know they deal with break and continue use. repeating the same question over again until it is right providing an option to quit and ...
Tiffany J Munn's user avatar
0 votes
1 answer
44 views

I don't know why, but only the '0' option works, unless the 'clear' command is removed or commented out. See the script: NUMERO=-1 while [ $NUMERO -ne 0 ]; do clear echo "------ M E N U -...
Luiz Moura's user avatar
0 votes
1 answer
69 views

Flag = 0; while Flag == 0 for x = 1:10 if x == 3 Flag = 1; end % end: if end % end; for end % end: while Can anyone tell me why the while loop condition is not ...
Alexander Savadelis's user avatar
0 votes
0 answers
59 views

I have code that has two warnings. The code is from a commandline Expense manager project that uses a List to save and access expenses. Saving and retrieving the List is done via serialisation and ...
Andruid929's user avatar
0 votes
3 answers
156 views

I'm currently taking a beginner programming course, and we are using Zybooks. I'm working on a participation activity where I am tasked with completing an existing program to verify that the string ...
PS Ormenda's user avatar
1 vote
2 answers
100 views

I was presented with this question as part of my Intro to Prog & Logic class. Problem 5: Write a simple program that the user can enter any number of positive and negative integer values and ...
Miranda Cataldi's user avatar
0 votes
1 answer
119 views

In Lua, are these two snippets exactly equivalent? repeat ... until <condition> while true do ... if <condition> then break end end At first glance they seem ...
user200783's user avatar
  • 14.5k
-6 votes
2 answers
69 views

This is a Python 3 question for loops using 'for' Why does the print(num-1) still execute at range 4? In my mind when range is 4 it should skip print(num-1) and go straight to else: print(num). for ...
Jay B.'s user avatar
  • 11
1 vote
5 answers
129 views

Im trying to do the below: file1: x.x.x.5 x.x.x.6 file2: router switch Trying to loop through both files to create two additional files each name in file2 as: ping_router.sh sudo /sbin/mtr -rn -c 30 -...
D' go's user avatar
  • 41
0 votes
0 answers
45 views

I had this piece of code: While match <> Nil Var block As New Glyph block.Abstract = match.SubExpressionString(1) block.Noun = match.SubExpressionString(2) block.Verb = match....
Anna Vahtera's user avatar
-3 votes
1 answer
68 views

I am writing this JavaScript code using the while loop that asks a user for there age. I've written the code but it accepts me even after filling ages below 18. How shall I go about it? I tried the ...
Emmanuel 's user avatar
0 votes
1 answer
97 views

The following code is simple and works when trying to compare previous values from one column to the next. The only problem is that it is displayed one row below where I want. So the numbers do not ...
user26136009's user avatar
2 votes
2 answers
83 views

I'm creating a script where multiple outputs from background processes are captured through while-read loop. However, it only works if I capture output directly to while loop. Trimmed down version of ...
decepticlown's user avatar
1 vote
3 answers
177 views

Suppose I have a piece of C code while(1) { switch(a){ case 1: if(b==1) break;//first break break;//second break } } ...
Turbo's user avatar
  • 87
-2 votes
1 answer
62 views

I am trying to increment the output by 2 (every line increment by 2) while reading in a file. Here is my code: Input.txt: green yellow grey purple SCRIPT: set infile [open "input.txt" r] ...
Chang's user avatar
  • 11
0 votes
1 answer
97 views

I'm trying to create a way of inserting aggregated data into a table by using a loop with a moving cursor. I want to count records in a 1h timeframe and compare it to the average number in ...
Mikis's user avatar
  • 11
1 vote
1 answer
59 views

I have a csv file test_list containing only lines of text: > cat $test_list test_name_1 test_name_2 > typeset -p test_list declare -- test_list="test_list.csv" I want to test that ...
jeannej's user avatar
  • 1,226
0 votes
0 answers
119 views

I have a JSON file which looks like this [ { Mem id:12345 DOB: 04041994 }, { Mem id:5678 DOB: 05061987 } ] I want to take each mem details and validate in my application using loops. ...
user29427449's user avatar
3 votes
3 answers
170 views

A number guessing C program; After the 4th iteration which prompts “well, is it 5 then?”, the character \n (enter) still remains in the buffer which then gets read by the first getchar() in the while ...
memory_pimp941's user avatar
1 vote
1 answer
149 views

I'm writing a script that will transfer large amounts of data to an SFTP server, and I'd like to have some sort of terminal print-out during the long loading time for troubleshooting/debugging. I'm ...
Jwok's user avatar
  • 752
1 vote
2 answers
128 views

This is a MRE of a larger bash script, that replaces characters in filenames based on a list of files and a character map. Instead of a file list from a file I'm reading in two "files" from ...
Ovski's user avatar
  • 713
0 votes
0 answers
36 views

I am using TRADER package in RStudio in my dendrochronology project and this error keeps popping up after entering the function growthAveragingALL(). Error in while ((!is.na(above[iil - 1, i])) & (...
user29574866's user avatar
2 votes
2 answers
62 views

from picozero import pico_led, Button, LED, Buzzer from time import sleep led16 = LED(16) button12 = Button(12, pull_up = False) button15 = Button(15, pull_up = False) buzzer14 = Buzzer(14) global ...
Lars Falc0n's user avatar
4 votes
4 answers
195 views

Only started learning Python a few days ago. I followed freecodecamp's while loop word guessing game tutorial and wanted to add the statement, "Wrong answer!" after every wrong guess. This ...
user29472044's user avatar

1
2 3 4 5
530