Discussions

Looking for practice while loop questions
I just went through a whole bunch of for loop exercises and I feel like I have a good understanding of it but I’m having a hard time finding practice while loop problems. Any good links to sites with specifically while loop exercises with solutions? All I’ve found bunches for loop and while ... More on discuss.python.org
🌐 discuss.python.org
0
December 27, 2022
Python while loop (coding exercise, three variables) - Stack Overflow
As I'm a total programming newbie, I need your advice concerning the coding exercise which I need to fulfil for the online course. Here is the instruction: mystery_int_1 = 3 mystery_int_2 = 4 More on stackoverflow.com
🌐 stackoverflow.com
Ideas for practicing for and while loops?

For: print out only even numbers between 1 and 100. Now do it without using an if statement.

While: Ask the user for a secret password. Keep going until they get it right. Now do the same without using an if statement.

These are probably the most basic ideas. Once you have them down, you can build on your knowledge.

More on reddit.com
🌐 r/learnpython
34
56
November 8, 2018
For loops and while loops

I get what you are saying :) I need a lot of practice for stuff to stick. When I was learning conditionals and looping, the best advice I got was to start with some practice problems, then make up similar problems with my own data and scenarios. For example, you could write a program to loop through a list of addresses and have it return some information about each entry. Or, you could write a program to take keyboard input and keep printing some result until you enter 'N' (the while loop in action). We were also told to try to solve the problems without using while or for loops to help motivate why you would want them in the first place. That really helped solidify the concepts for me, because you can write code without the loops, but it gets long and tedious... Btw, another link I used was https://www.practicepython.org/.

More on reddit.com
🌐 r/learnpython
6
3
December 22, 2016
🌐
PYnative
pynative.com › home › python exercises › python if else, for loop, and range() exercises with solutions
Python if else, for loop, and range() Exercises with Solutions
April 19, 2025 - Exercise 1: Print first 10 natural numbers using while loop ... # program 1: Print first 10 natural numbers i = 1 while i <= 10: print(i) i += 1Code language: Python (python) Run
🌐
w3resource
w3resource.com › python-exercises › python-conditional-statements-and-loop-exercises.php
Python conditional statements and loops - Exercises, Practice, Solution - w3resource
This resource offers a total of 220 Python conditional statements and loops problems for practice. It includes 44 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
🌐
Pythonista Planet
pythonistaplanet.com › python-while-loop-examples
18 Python while Loop Examples and Exercises – Pythonista Planet
February 2, 2023 - 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…
🌐
Pythontutorials
pythontutorials.eu › basic › loops
Loops: for and while // Python Tutorials
You can also loop through a str, ... out each character on a separate line. After the loop, print out 'Done!' ... A while loop executes a code block until a particular condition is no longer True....
🌐
LearnPython.com
learnpython.com › blog › python-loop-exercises
10 Python Loop Exercises with Solutions | LearnPython.com
Notice that the loop prints the values until 10 – that is, one less than the stop value. Since you’ll be printing things all the time in Python, check out How to Print in Python – A Detailed Guide for Beginners. This function can do more than you think. Try the above exercise using a while ...
🌐
Tutorials
zframez.com › tutorials › chapter 6: python while and for loops: examples and explanations
Chapter 6: Python While and For Loops: Examples and Explanations - Tutorials
October 16, 2024 - In this chapter, you’ll learn how to use while loops with the else clause, how to control output formatting using Python’s print() function, and how to iterate over a range of numbers or lists with for loops.
Find elsewhere
🌐
Nanyang Technological University
libguides.ntu.edu.sg › python › whileloops
1.16 While loops - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
July 22, 2025 - With the continue statement, we can skip over a part of the loop where an additional condition is set, and then go on to complete the rest of the loop. ... With the else statement, we can run a block of code once when the condition no longer is true. ... Assign the integer 10 to variable i ...
🌐
Python.org
discuss.python.org › python help
Looking for practice while loop questions - Python Help - Discussions on Python.org
December 27, 2022 - I just went through a whole bunch of for loop exercises and I feel like I have a good understanding of it but I’m having a hard time finding practice while loop problems. Any good links to sites with specifically while loop exercises with solutions? All I’ve found bunches for loop and while ...
🌐
Sololearn
sololearn.com › en › Discuss › 2706335 › python-while-loop-hit-or-miss-game-multiple-user-input
PYTHON WHILE LOOP HIT OR MISS GAME MULTIPLE USER INPUT | Sololearn: Learn to code for FREE!
pythonwhileloop · 24th Feb 2021, 7:42 PM · Courtney Ruth · 20 Answers · Answer · + 4 · For me this worked: score = 100 a = 0 while a <= 3: i = input() if(i == "hit"): score = score + 10 if(i == "miss"): score = score - 20 a = a + 1 print(score) 8th Jun 2021, 10:30 AM · Felix Horn · + 3 · its odd though that i havent gone through learning for loops, the curriculum has only covered while. for loops are next. but the point of this exercise is to use a while loop ·
🌐
Proficientpython
proficientpython.com › 2-loops-&-lists › 2-exercise-while-loops.html
Proficient Python: Exercise: While loops
def product_of_numbers(end): """Returns the product of all the numbers from 1 to the end number, including the end number. >>> product_of_numbers(1) 1 >>> product_of_numbers(2) 2 >>> product_of_numbers(3) 6 >>> product_of_numbers(10) 3628800 """ result = 1 counter = 0 while counter < end: result *= counter counter += 2 return result
🌐
Computer Science Newbies
csnewbs.com › python-6b-while-loops
Python | 6b - While Loops | CSNewbs
The continue command will move to the next iteration (it can be considered as starting the loop again). ... The program below allows numbers to be entered and keeps track of a running total. Entering 1 inputs a number, 2 displays the total and 3 stops the program. total = 0 while True: choice = input("\nType 1 to enter, 2 for a total and 3 to stop: ") if choice == "1": number = int(input("Enter a number: ")) total = total + number continue elif choice == "2": print("The total is" , total) continue elif choice == "3": break print("\nProgram finished.")
🌐
Scribd
scribd.com › document › 687466145 › Python-Loop-Exercise
Python Loop Exercise | PDF
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Programiz
programiz.com › python-programming › while-loop
Python while Loop (With Examples)
while True: user_input = input("Enter password: ") # terminate the loop when user enters exit if user_input == 'exit': print(f'Status: Entry Rejected') break print(f'Status: Entry Allowed') ... Before we wrap up, let’s put your knowledge of Python while loop to the test!
🌐
GeeksforGeeks
geeksforgeeks.org › python › loops-in-python
Loops in Python - GeeksforGeeks
In Python, a while loop is used to execute a block of statements repeatedly until a given condition is satisfied.
Published   1 month ago
🌐
Learn Python
learnpython.org › en › Loops
Loops - Learn Python - Free Interactive Python Tutorial
# Prints out 0,1,2,3,4 count = 0 while count < 5: print(count) count += 1 # This is the same as count = count + 1 · break is used to exit a for loop or a while loop, whereas continue is used to skip the current block, and return to the "for" or "while" statement.