About 1,480,000 results
Open links in new tab
  1. Python: How to keep repeating a program until a specific input is ...

    There are two ways to do this. First is like this: inp = raw_input() # Get the input. if inp == "": # If it is a blank line... break # ...break the loop. The second is like this: inp = raw_input() # Get the …

  2. python - Repeating a while loop after user input - Stack Overflow

    Jun 23, 2018 · To put that in a while loop, ask for the user input after the function call and break if it is 'y'. while True: stop = int(input('Sum even up to... ')) print(sum_even(stop)) if input('Type …

  3. python - Repeating while loop, until cancel - Stack Overflow

    Jan 31, 2012 · You need to use the break command to exit the loop. while True: new_short=raw_input('Country Name in short:') new_full=raw_input('Country Name in full:') …

  4. How to repeat a function N times or indefinitely in Python

    Feb 16, 2023 · To repeat a function indefinitely in Python, you need to use the while loop and call the function in that loop. To stop the function, you need to write an if statement with a condition …

  5. 8 Python while Loop Examples for Beginners - LearnPython.com

    Feb 5, 2024 · This Python while loop can be translated to plain English as “while i is less than 5, print i and increment its value by 1”. There are several use cases for while loops. Let’s …

  6. Python While Loops - W3Schools

    Python has two primitive loop commands: With the while loop we can execute a set of statements as long as a condition is true. Note: remember to increment i, or else the loop will continue …

  7. How to Use the repeat() Function in Python? - Python Guides

    Jan 4, 2025 · Learn how to use Python's `repeat()` function from the `itertools` module! This tutorial covers syntax, examples, and tips for repeating values in loops.

  8. Using For and While Loops for User Input in Python - Stack Abuse

    In this Byte, we've explored how to use for and while loops in Python to take in user input. We've seen how these loops allow us to repeat a block of code until a certain condition is met, which …

  9. python - while loop same word - Stack Overflow

    Mar 20, 2021 · The problem here is that you're asking you're code to stop the loop only if the input it's exactly the input word, instead of asking it to stop if it contains already contains that word. …

  10. 18 Python while Loop Examples and Exercises - Pythonista Planet

    In Python programming, we use while loops to do a task a certain number of times repeatedly. The while loop checks a condition and executes the task as long as that condition is satisfied. …

Refresh