[Solved] Python raw_input to extract from dictionary

Solution while True: prompt = int(raw_input(” Enter ID of person you would like to search for: “)) if prompt > 100: print(“Please try again”) continue elif prompt < 1: displayPerson(prompt,persons) else: break print(“Terminated.”) Explanation You enter the loop and get an ID from the user. If prompt > 0: display the person Otherwise, break out … Read more

[Solved] Trying to test if an input is odd or even

You’d better simplify all of this, you don’t need to call your method multiple times : public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (writeAndCheckEven(Integer.parseInt(scanner.nextLine()))) { System.out.println(“You added an even number, go on”); } System.out.println(“You added an odd number, done!”); } private static boolean writeAndCheckEven(int number) { return number % 2 … Read more

[Solved] Do and While Loop

You can use the while loop as follows: int i=1; while(i<=7) { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, &raise, &totraise); calcNewSal(sal, raise, &newsal, &totnewsal); calcTotSal(&sal, &totsal); print(sal, rate, raise, newsal, totsal, totraise, totnewsal); fflush(stdin); i++; } And the do-while as follows: int i=1; do { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, … Read more

[Solved] mysql_fetch_array -> 2 mysql queries

You only need one function, run a join in your query SELECT customer_id, name FROM customer_ids INNER JOIN customers ON customer_ids.customer_identify = customers.identify This should get the required fields then jun run your loop normally 0 solved mysql_fetch_array -> 2 mysql queries

[Solved] How to end a python program without it going to the next line of code [duplicate]

while True: choice = input (“Do you want to play?”) if choice == “yes” print(“Great!”) break # Go to the game elif choice == “no” print(“Goodbye.”) break # nothing else: print(“Please answer yes or no.”) solved How to end a python program without it going to the next line of code [duplicate]

[Solved] infinite while loop python

Your second while loop has no break point!!! Your first while loop runs until it detects motion and then enters the second loop, and your second loop runs forever. If you want both loops to work simultaneously then you should use threads!!! If not then make a break point in second loop. Simple example: import … Read more