logo
down
shadow

Stuck in while loop


Stuck in while loop

By : kavya h s
Date : November 21 2020, 11:01 PM
To fix the issue you can do I'm trying to make a dice tosser for my nephew so he can play boardgames without dice. i have got stuck in a while loop if even if i enter a condition that is true. I'm trying to get him to select which dice he wants to use but if he selects a wrong dice then it asks him to enter it again. my code is ... , Try This:
code :
    dice_select = int(input('Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12:  '))
    while not (dice_select == 4 or dice_select == 6 or dice_select == 12):
        dice_select = int(input('Sorry thats not quite right. Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12:  '))


Share : facebook icon twitter icon
Using do while loop and while loop to write a program that will run random guessing game...i stuck at the do while loop

Using do while loop and while loop to write a program that will run random guessing game...i stuck at the do while loop


By : Nate Jahns
Date : March 29 2020, 07:55 AM
hop of those help? First of all the formula you are using to calculate the random number is wrong. Suppose that min is 10, and max is 12. Then the rand() % max could be, let's say, 10. Adding min (10), the number to guess would be 20 - far greater than max... It should be secret = rand() % (max-min +1) + min; (if your interval is [min, max]).
Now to your question - as far as I understood you want to know if the entered guess is a number. Here is what you can do:
code :
    while(1)
   {
        cin >> guess;

         if(cin){
     if (guess > max){
         cout << "Too high!\n\n";
         cin.clear();
         cin.ignore();
         continue;
     }
     else if (guess < min){
         cout << "Too low!\n\n";
         cin.clear();
         cin.ignore();
         continue;
     }
     else if(guess != secret){
         deposit-=bet;
         cout<< "Sorry, U lose RM "<< bet;
     }
     else if(guess == secret){
         bet*=10;
         deposit+=bet;
         cout<< "\n\nCongratulation! U earn RM "<< bet;
     }
     break;
 }
 else
 {

     cin.clear();
     cin.ignore();
     cout << "Error! You did not enter a number!" << endl;
     continue;
 }
}
    do{
     cout<< "Wanna play again (y/n)? "; 
     cin>> reply;

     if( reply!='y'&& reply!='n')      
         cout<< "\nReally? Ok, try again! \n";

 }while(reply!='n' && reply!='y');

 if( reply =='y')
         goto AA;

 if(reply=='n'){
     cout<< "\n\n\n"<< setw(80)<< setfill('+')<< "\n\n";
     cout<< setw(30)<< "THX FOR PLAYING! UR CURRENT BALANCE IS RM "<< deposit<< "\n\n";
     cout<< setfill('+')<< setw(80)<< "\n";
 }
cout << "Pls enter the min of secret number\n";
while (!(cin >> min) || min<=0){

        cout << "Pls enter the min of secret number\n";
        cin.clear();
        cin.ignore();

}
Trying to write a validation loop in Xcode 7 (Swift 2) for an iOS mobile app - stuck on infinite loop

Trying to write a validation loop in Xcode 7 (Swift 2) for an iOS mobile app - stuck on infinite loop


By : Prudhvi Gsv
Date : March 29 2020, 07:55 AM
it should still fix some issue I am attempting to create an app (iOS) where a random number generator is used to display an arithmetic problem. The random number generator will decide what operation the user will perform (multiplication, subtraction, addition) and which operands are used. The user can select the difficulty level by using a segmented control. , If you want to break the while loop only:
code :
     while newAnswer != correctAnswer {
                feedback.text = "Try Again!"
                enteredAnswer.text = ""
                newAnswer = Int(textAnswer)!
                i+=1
                if i == 3 {
                    break
                }
            }
if newAnswer != correctAnswer {
    feedback.text = "Try Again!"
    enteredAnswer.text = ""
    newAnswer = Int(textAnswer)!
    i+=1
    if (i<3){
        return
    }
}
IE-Automation: Stuck with debuging only first instance of loop is done correctly, but loop does not break

IE-Automation: Stuck with debuging only first instance of loop is done correctly, but loop does not break


By : M0rb1dD3v1l
Date : March 29 2020, 07:55 AM
I hope this helps . I notice you never reset the variable ActRw, which means you start copying to row 1 of the first worksheet you create, then the second worksheet you create you start your copying at the row after the one you finished the first sheet at.
So are you sure you aren't writing anything to the second sheet - or are you just writing it at row 100 or something?
code :
ActRw = 0
Dim ActRw  As Long
While function stuck in loop, seems that half of loop doesn't execute

While function stuck in loop, seems that half of loop doesn't execute


By : Monika Wanot
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Presumably Vote.find does its work asynchronously (and similarly for Vote.findOneAndUpdate). Your for and while loops do not. So delegationsLeft will never be anything but 1 during the course of your loop.
If you're interacting with asynchronous results, you can't use while (or for or do-while). Instead, you need to schedule the next "iteration" of the "loop" from within the asynchronous callback.
iteration getting stuck in loop(infinite loop) while tracking image

iteration getting stuck in loop(infinite loop) while tracking image


By : Y. C.
Date : March 29 2020, 07:55 AM
Does that help I believe the issue is with your indentation. Currently it reads something like this:
code :
While True:
    for some_stuff in stuff:
        if (conf < 60):
            add a timestamp record to attendence.loc
        else:
            set some Id

        if (conf > 75):
            write an image file

    # This runs on every while loop
    cv2.imshow('im',im)
        if (cv2.waitKey(1) == ord('q')):
            break

# This runs once while is no longer True (after pressing `q`)
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
Hour,Minute,Second = timeStamp.split(":")
fileName = "Attendence\Attendence_" +date+"_"+ Hour+"-"+Minute+"-"+Second+".csv"
attendence.to_csv(fileName,index=False)
def write_file(attendance):
    ts = time.time()
    date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
    timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
    Hour,Minute,Second = timeStamp.split(":")
    fileName = "Attendence\Attendence_" +date+"_"+ Hour+"-"+Minute+"-"+Second+".csv"
    attendence.to_csv(fileName,index=False)

While True:
    for some_stuff in stuff:
        if (conf < 60):
            add a timestamp record to attendence.loc
            write_file(attendence)
        else:
            set some Id

        if (conf > 75):
            write an image file

    # This runs on every while loop
    cv2.imshow('im',im)
        if (cv2.waitKey(1) == ord('q')):
            break
Related Posts Related Posts :
  • Django Form Based on Variable Attributes
  • Relocate all the evens
  • How to scrap span ids' texts in beautifulsoup in the following html?
  • How to generate random number in a given range as a Tensorflow variable
  • Gradient Descent Variation doesn't work
  • Python 2.7 - search for a particular URL on a webpage with ajax
  • How to configure Luigi task retry correctly?
  • web.py : an urlencoded slash into args
  • Use of pyzmq's logging handler in python
  • How to count the number of a particular entry. python
  • devide int into lower whole ints
  • Access atribute of every object in pandas dataframe column
  • Combine Dataframe rows on conditions
  • Select closest date (or value) in pandas / python
  • Pycharm and remote interpreter (Docker) shows errors but runs fine
  • Get started to launch google-cloud-ml with my own dataset
  • Multiprocessing: use only the physical cores?
  • Django Login Custom Auth works locally but not on production server
  • Python: Invalid HTTP basic authentication header with long base64 string
  • How can I request several pages without wating for the output?
  • Flask Response vs Flask make_response
  • python linear regression predict by date
  • How to get pandas dataframe where columns are the subsequent n-elements from another column dataframe?
  • MYSQL: "Access denied for user 'X'@'localhost' (using password: YES)" PYTHON
  • install scipy package via pycharm in windows 10 64 bit - python 3.5
  • Update time in linux and solaris machines from robot framework
  • Complex pandas isin function
  • Averaging over every n elements of an array without numpy
  • An elegant way of inserting multiple arguments
  • IntegrityError:NOT NULL constraint failed: chatapp_chat.message
  • Indexing of 3d numpy arrays with 2d arrays
  • Creating a mean of columns with csv writer
  • Reading in environment variables from an environment file
  • Collapse duplicate rows with pandas
  • How can I use skyfied to convert SGP4 TEME coordinate to ECEF?
  • How to modify object in Python's Rtree index
  • Create Hexbin plot with pandas dataframe using index and columns names as x and y
  • SQLAlchemy query returns no data if a database field is empty
  • Python pandas column asignment between dataframe and series does not work
  • ValueError: Unknown label type: array while using Decision Tree Classifier and using a custom dataset
  • Trouble accessing exif information with PIL.Image._getexif()
  • Use all coordinates in a grid except with certain value
  • Why for loop is splitting strings of user input?
  • How can I add two variable and assign to result variable in Python?
  • Error when parsing timestamp with pandas read_csv
  • Slicing arrays based on boolean array in python
  • Feeding scipy.sparse() sparse matrices into CVXOPT
  • How to separate a irregularly cased string to get the words? - Python
  • Pandas: replace some values in column if that contain a substring
  • Fabric does not close the ssh connection
  • Python Creating Classes Code
  • When will train() method in easy_seq2seq stop?
  • How to split each element of the RDD in spark with python?
  • Read in csv file in python, round the values and write back to file
  • How to properly close a QWidget-window in an API with PythonQt
  • How to know which segment a value reside in
  • pandas: convert multiple categories to dummies
  • 'Options' object has no attribute 'get_all_field_names'
  • Customize django filter model field
  • NLTK tag Dutch sentence
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com