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. Answer from vikingvynotking on reddit.com
🌐
HackerRank
hackerrank.com › challenges › python-loops › tutorial
Loops | HackerRank
To control the loop in this problem, use the range function (see below for a description). There are two kinds of loops in Python. ... When using a for loop, the next value from the iterator is automatically taken at the start of each loop. When using a while loop, the iterator must be initialized ...
Discussions

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 6, 2018
Python loop exercise help
Hi, I am new to coding. Why does my code still slice the list when it gets to 11, despite it being an odd number? The function should be removing any even number from the front of the list Intended output should be [11, 12, 15] def delete_starting_evens(my_list): while len(my_list) > 0: for ... More on discuss.python.org
🌐 discuss.python.org
0
0
March 24, 2024
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
0
December 24, 2022
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 20, 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
🌐
W3Schools
w3schools.com › python › python_while_loops.asp
Python While Loops
With the break statement we can stop the loop even if the while condition is true: ... Note: The else block will NOT be executed if the loop is stopped by a break statement. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
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!
🌐
Python.org
discuss.python.org › python help
Python loop exercise help - Python Help - Discussions on Python.org
March 24, 2024 - Hi, I am new to coding. Why does my code still slice the list when it gets to 11, despite it being an odd number? The function should be removing any even number from the front of the list Intended output should be [11, 12, 15] def delete_starting_evens(my_list): while len(my_list) > 0: for num in my_list: if num % 2 == 0: my_list = my_list[1:] else: my_list[0:] return my_list print(delete_starting_evens([4, 8, 10, 11, 12, 15])) Output: [12, 15]
Find elsewhere
🌐
Mkzia
mkzia.github.io › eas503-book › chapters › 06 › while_loop_exercises.html
6.3. While Loop Exercises — EAS503: Python for Data Scientists
end_number = int(input('Enter an integer number: ')) current_number = 0 while current_number <= end_number: if current_number % 2 == 0: print(current_number) current_number += 1
🌐
University of Central Florida
cs.ucf.edu › ~dmarino › ucf › juniorknights › python1 › Python-Cht3.pdf pdf
(Python) Chapter 3: Repetition 3.1 while loop Motivation
accumulator variables is critical. It is used in many practical programs. Let’s take a look at a program that solves this problem and trace through the first few steps ... Initially, the Boolean expression for the while loop is true, since count, which is 1, is less than or
🌐
Softuni
python-book.softuni.org › chapter-07-complex-loops.html
7.1. More Complex Loops · Programming Basics with Python
You can test your solution here: https://judge.softuni.org/Contests/Practice/Index/1057#6. The next type of loop construction that we will become familiar with while studying programming is the while True + break loop (for short while + break loop). Its idea is to repeat a block of code over and over again until explicit termination of the loop, usually after an if statement in the body of the loop. Here's what this loop looks like in Python code:
🌐
Real Python
realpython.com › python-while-loop
Python while Loops: Repeating Tasks Conditionally – Real Python
March 3, 2025 - The typical way to write an infinite loop is to use the while True construct. To ensure that the loop terminates naturally, you should add one or more break statements wrapped in proper conditions: ... This syntax works well when you have multiple reasons to end the loop. It’s often cleaner to break out from several different locations rather than try to specify all the termination conditions in the loop header. To see this construct in practice, consider the following infinite loop that asks the user to provide their password:
🌐
Python.org
discuss.python.org › python help
Looking for practice while loop questions - Python Help - Discussions on Python.org
December 24, 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 ...
🌐
BrainStation®
brainstation.io › learn › python › while-loop
Python While Loop (2026 Tutorial & Examples) | BrainStation®
February 4, 2025 - Write the logic inside the while loop that should be executed if the condition is True in step 2. The condition is always checked first and only if it’s True, the logic inside of the while loop will be executed otherwise the code that follows ...
🌐
Teclado
teclado.com › 30-days-of-python › python-30-day-8-while-loops
Day 8: While Loops | Teclado
When we want to specify an infinite loop, we want to write an expression which is always going to be evaluate to a truthy value. A good example is the Boolean value, True, which is always going to evaluate to True if we test its truth value. I don't recommend you run this code, but we could ...
🌐
CS-IP-Learning-Hub
csiplearninghub.com › questions-of-while-loop-in-python
40 Important Questions of While loop in Python (Solved) Class 11 - CS-IP-Learning-Hub
January 15, 2023 - Important Questions of While loop in Python (Solved) Class 11. Practice exercise of loop in python. Python loop assignment.
🌐
Python Course
python-course.eu › python-tutorial › loops.php
19. While Loops | Python Tutorial | python-course.eu
Chapter on loops with simple and practical examples using while loops in Python.
🌐
LearnPython.com
learnpython.com › blog › python-loop-exercises
10 Python Loop Exercises with Solutions | LearnPython.com
January 29, 2024 - A great way for beginners to learn Python is by doing hands-on exercises. In this article, you’ll get 10 Python exercises for writing loops. You’ll also get the solutions with detailed explanations.
🌐
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…
🌐
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 - Learn practical Python programming skills for basic data manipulation and analysis. ... This will print the data '1' without stopping as long as i is less than 5. Run the codes below. We can stop this by adding a line of code to increase the value of i with each iteration. ... With the break statement we can stop the loop even if the while condition is true.
🌐
Vista Academy
thevistaacademy.com › home › blog › some important questions of while loop in python to practice (with answers)
20+ While Loop Questions in Python (With Answers & Practice Problems)
August 3, 2025 - Practice key while loop questions in Python with answers. Includes syntax errors, indefinite loops, execution count, and beginner-friendly examples.