26,492 questions
-5
votes
4
answers
130
views
Python while loop not stopping when element is found in a tuple [closed]
I am trying to search for a number in a tuple using a while loop in Python. The program finds the element , but it does not stop and continues to run until the end of the tuple. Here is my code:
...
3
votes
2
answers
63
views
I'm getting an 'index out of bounds' error using solve_ivp
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....
-3
votes
1
answer
119
views
How do I only accept specific string input [closed]
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 ...
-2
votes
2
answers
130
views
My while loop is looping despite reaching the break. It loops once then goes on with the rest as normal. I am at my wits end [closed]
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 ...
0
votes
2
answers
94
views
partclone print progress every nn seconds to a new line in bash
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 ...
3
votes
1
answer
90
views
Problem with nested loop logic and indentation in python
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 ...
3
votes
3
answers
215
views
While loop in C clipboard program doesn't work properly?
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&...
1
vote
2
answers
83
views
Using sed -i within a loop
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 ...
2
votes
1
answer
146
views
Why is my string not printing to PowerShell in C on second function call?
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 ...
-9
votes
1
answer
146
views
Using the .find() function in a loop [closed]
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 = ...
0
votes
2
answers
167
views
C program won't skip second half of While statement [closed]
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 ...
0
votes
1
answer
154
views
While loops are testing faster than for loops - should I use while loops instead of for loops?
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-...
0
votes
0
answers
81
views
ETA/Timer logic issues with indicatif
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 ...
-4
votes
4
answers
180
views
"break" function doesn't work correct within "while" cycle
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 ...
3
votes
1
answer
96
views
Python While loop is executed, but then it fails to execute an if statement after it
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,...