26,492 questions
0
votes
2
answers
76
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
79
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
205
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
79
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
132
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
140
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
165
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
144
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
71
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
178
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
85
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,...
1
vote
2
answers
113
views
Why is n mod n = n, instead of 0 in for loop, but correctly 0 in while loop? [closed]
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 "...
-1
votes
2
answers
96
views
While statement not continuing when calling a function in python
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&...
2
votes
3
answers
143
views
Can someone help me understand this unexplained behaviour in C char arrays?
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 '...
0
votes
2
answers
77
views
Different Variable in while loop [duplicate]
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 =...