while-loop

How to fix a while loop that goes on forever in Python?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 01:46:34
问题 I am trying to create a simple while loop that will run the commands start, stop, quit, and help. Start, stop, and help will just display some printed text. After they are run, I want it to keep going on to another command. However, on quit I want the whole program to stop. input_command = input("> ").lower() while input_command != "quit": print(input_command) if input_command == "start": print("The car is ready! VROOM VROOM!") print(input_command) elif input_command == "stop": print("Car

Bash script fails to read entire file

孤者浪人 提交于 2019-12-25 01:44:43
问题 I have a bash script for backing up a set of folders/files. The script loops through a pre-configured file to determine how to copy the folder/file. The problem I am facing is the script exits the while loop after processing the first "file" entry (2nd column value). Here is the script. #!/bin/bash sudo crontab -l > /home/ipaccess/crontab.txt DATE=`date +%m-%d-%Y` TARGETDIR="/exports/backup/Web-Server/$DATE/" BACKUPLIST="/home/ipaccess/backup/backuplist" ssh 172.29.32.246 mkdir -p $TARGETDIR

I want to be able to extract two different sequences from one line

若如初见. 提交于 2019-12-25 01:44:17
问题 I want to be able to extract two different sequences from one line. For example: atg ttg tca aat tca tgg atc atg ttg tca aat tca tgg atc tag I want to create a loop where the program will read from the 1st atg to tag , output that sequence into a file, as well as take the second atg read to tag , output that sequence into the same file. Output I want: atg ttg tca aat tca tgg atc atg ttg tca aat tca tgg atc tag atg ttg tca aat tca tgg atc tag How can I go about this? Thank you for the help.

how do I break infinite while loop with user input

ε祈祈猫儿з 提交于 2019-12-25 01:28:49
问题 I'm very new to Python. I made a math program that keeps generating a new math problem every time you get the last one right. however I don't know how to exit/break the while True loop and switch from addition to subtraction. import random while True: question = input("press 1 for addition, press 2 for subtraction.") if question == "1": print("Try your skill at these problems.") number1 = random.randint(0, 9) number2 = random.randint(0, 9) while True: print(number1, "+", number2, "=") number3

When I run my code twice (after a While/DoWhile), the scanf does not work as intended. (Im Using Visual C++ Windows Console Application)

こ雲淡風輕ζ 提交于 2019-12-25 00:53:17
问题 I'm new to programming and I was trying to make a calculator and I'm adding a while loop, so that if you want to repeat you just type "1" and the program repeats. The problem is if I repeat it the scanf() breaks and no longer allows me to type something into the command line. (I am using Visual C++ Windows Console Application) I was trying to use fflush(stdin) to clear the keyboard buffer, this did not work either. #include "pch.h" #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include

While/foreach Loops Returning Four of the Same Row

守給你的承諾、 提交于 2019-12-25 00:36:15
问题 I can't seem to figure out why this script is doing this, so I need someone with more experience/better eyes to tell me what the issue is. I can't seem to find anything elsewhere online, but I may be wording my search terms wrong. This set of While/Foreach loops works just fine except that it spits out the same row four times: $squery = "SELECT username, name FROM name_records"; $sresult = mysql_query($squery); while($srow = mysql_fetch_array($sresult)) { foreach ($srow as $scell) { $username

Loop to check time in VB.NET

两盒软妹~` 提交于 2019-12-25 00:14:59
问题 So I'm kind of new to VB and am just playing around with a little project, I currently need a loop that is constantly checking the systems clock to see if it's equal to a certain time. While Not myTime.Hour = 24 If TimeOfDay = newTime Then nfi.ShowBalloonTip(15) intRandNumb = RandomNumber(1, 15) dblAddMinutes = intTime + intRandNumb newTime = TimeOfDay.AddMinutes(dblAddMinutes) End If End While I have this right now, but obviously it's grinding everything to a halt and using 50% of my cpu in

Javascript while loop waits for increment instead of becoming an infinite loop

回眸只為那壹抹淺笑 提交于 2019-12-24 23:44:05
问题 Right now in my nodejs socket.io 'game' I would like to cycle through all users currently online*, each having their opportunity to be a leader and click a button that would sequentially make the next user the leader (to, again, click a button that makes the next user the leader. You get the idea). My issue is that when I make the while loop wait for the 'leader' socket to trigger the leaderSelection event to increment the while loop, the while loop instead creates an infinite loop, crashing

Read full message in a while loop in bash

妖精的绣舞 提交于 2019-12-24 21:53:28
问题 I connect to a server by /dev/tcp to receive incoming xml messages. The script below is running well, but if there is an blank character in the xml message, the message is abrupt. But I need the to read full message. Can I solve this by integrate the closing xml-tag in the while-loop? #!/bin/bash exec 3<>/dev/tcp/192.168.24.23/1234 processResponse() { RESPONSE=$1 if [[${RESPONSE:0:10} == "<firsttag>" ]]; then curl -X POST --data "postdata=$RESPONSE" http://localhost/index.php fi } while read

Program ended without completing the task

ぃ、小莉子 提交于 2019-12-24 18:39:43
问题 When I run my script, it is ended before completing the task that is in while loop. driver = webdriver.Chrome() driver.get('http://example.com') #input("Press any key to continue1") s_b_c_status = "False" while s_b_c_status == "True": try: if(driver.find_element_by_xpath("//div[@role='button' and @title='Status']")): s_b_c_status = "True" except NoSuchElementException: s_b_c_status = "False" if(s_b_c_status == "True"): print("Scanning Done!") else: print("Error") As my site is not having the