About 49,200,000 results
Open links in new tab
  1. python - How to ask a string again if the wrong answer is entered ...

    Oct 4, 2016 · Firstly, you are only asking for the answer once at the moment. You need to put answer = input() in a while loop. Secondly, you need to use == instead of is: print("Hello there, …

  2. How to loop to ask question again using if-else statements python

    Apr 2, 2021 · This solution will work with multiple incorrect answers, and not get stuck in an endless loop. Anyhow, here you go: def main(): # Generate two random numbers between 1 …

  3. python - Asking the user for input until they give a valid response ...

    Apr 25, 2014 · How do I ask for valid input instead of crashing or accepting invalid values (e.g. -1)? The simplest way to accomplish this is to put the input method in a while loop. Use …

  4. If the user enters an invalid input, how can I code it so that ... - Reddit

    Nov 1, 2022 · put input () inside 'while True' loop and only break if input is correct. I was doing something like this the other day, maybe this would work? while True: if input () != (first option …

  5. How to loop back to question if answer is incorrect? : r ... - Reddit

    You can use a loop construct such as while. The example code is very similar to what you want to do. Note the use of str.strip() to remove whitespace https://wiki.python.org/moin/WhileLoop

  6. [Solved] python | How do I make the question repeat if the

    How do I make the question repeat if the user enters the wrong data? I want to make a score counter for a card game, the problem is that there are two optional rounds that can be played, …

  7. Repeat question (for loop) - Python Forum

    Jun 17, 2020 · With the current code, you are looping over the same question 5 times before you get to the if statement. it's not clear why you want to ask 5 times the question - is it that you …

  8. Solved I would like to know how to re-ask a question in - Chegg

    Here’s the best way to solve it. Here is the correct code: Please comment below if you still have any doubts. # validNumber function can check if the input given by the user is valid that is it …

  9. How to make python code go back to the original question after it hits ...

    Aug 25, 2020 · Instead of allowing the user to enter the answer again, the code quits and they have to go through the whole thing. How can I make it so that they get to return to the original …

  10. How to ask for input again, after initial input has been given ... - Reddit

    Jan 27, 2023 · Create a function, which asks the user until the user was able to input rock, paper or scissors. def ask_user(): choices = ("rock", "paper", "scissors") while True: user_input = …

  11. Some results have been removed
Refresh