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
🌐
W3Schools
w3schools.com › python › python_while_loops.asp
Python While Loops
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... 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 forever...
🌐
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
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 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
Practice Dart - exercises for beginners
Don't forget codingame.com. Also https://da-bootcamp.firebaseapp.com/?course=start_programming_dart More on reddit.com
🌐 r/dartlang
5
41
October 25, 2019
Some while loop exercises

What can maybe help as well is to run the snippets at http://www.pythontutor.com/visualize.html as then you can walk through them step by step, also seeing the values of the variables.

More on reddit.com
🌐 r/learnpython
9
2
February 2, 2019
🌐
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
🌐
BrainStation®
brainstation.io › learn › python › while-loop
Python While Loop (2026 Tutorial & Examples) | BrainStation®
February 4, 2025 - Each time you spend money, you will print the remaining amount of money left in the piggy bank. Create a variable called piggy_bank_balance and assign it a value of 100 to start with. Write a while loop as follows to spend money and print the ...
🌐
HolyPython
holypython.com › home › intermediate python exercises › exercise 9: while loop
Improve your Python skills with Exercise 9: While Loop | HolyPython.com
April 4, 2024 - def name_adder(list): i = 0 new_list = [] while i < len(list): if list[i] != "": new_list.append(list[i]) i = i+1 return new_list ... Check out Holy Python AI+ for amazing Python learning tools.
🌐
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 ...
🌐
Pythontutorials
pythontutorials.eu › basic › loops
Loops: for and while // Python Tutorials
You can also loop through a str, in which case you get individual characters as if you were looping through a list of characters. Use a for loop through loop through a str with the first five letters of the alphabet. Print out each character on a separate line.
Find elsewhere
🌐
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…
🌐
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 - Learn how to use while and for loops in Python with practical examples. This tutorial covers while loops, else with while loops, for loops, and the range function.
🌐
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.
🌐
Teclado
teclado.com › 30-days-of-python › python-30-day-8-while-loops
Day 8: While Loops | Teclado
Hopefully this wasn't too difficult, ... around to help on our Discord server, so feel free to drop by and ask any questions. 1) Write a short guessing game program using a while loop....
🌐
Learn with Yasir
yasirbhutta.github.io › python › docs › loops-while › practice-and-progress › exercises-loops-while.html
Python While Loop Exercises: Practice & Master Loops | Learn with Yasir
Write a program that asks the user for a number `n` and calculates the sum of numbers from 1 to `n` using a `while` loop. ... Write a program to print the multiplication table of a given number using a `while` loop. ... Write a program to count the number of digits in a given number using a ...
🌐
GitHub
github.com › Asabeneh › 30-Days-Of-Python › blob › master › 10_Day_Loops › 10_loops.md
30-Days-Of-Python/10_Day_Loops/10_loops.md at master · Asabeneh/30-Days-Of-Python
Iterate 10 to 0 using for loop, do the same using while loop. Write a loop that makes seven calls to print(), so we get on the output the following triangle: ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ... 0 x 0 = 0 1 x 1 = 1 2 x 2 = 4 3 x 3 = 9 4 x 4 = 16 5 x 5 = 25 6 x 6 = 36 7 x 7 = 49 8 x 8 = 64 9 x 9 = 81 10 x 10 = 100 · Iterate through the list, ['Python', 'Numpy','Pandas','Django', 'Flask'] using a for loop and print out the items.
Author   Asabeneh
🌐
Python Lobby
pythonlobby.com › home › python loop exercises with solution – for loop(), while loop() etc.
Python Loop Exercises with Solution – for loop(), while loop() etc.
October 9, 2022 - # Reverse a number n = int(input("Enter number: ")) rev = 0 while(n != 0): rem = n % 10 rev = rev * 10 + rem n = n // 10 print(rev) # output # 12534
🌐
Guamcc
ifs.guamcc.edu › adminftp › academics › computer › ycflores › CS212 › while_loop_exercises.pdf pdf
In-Class Exercise - Python While Loop Exercises (Save As: whileloop.py)
In-Class Exercise - Python While Loop Exercises (Save As: whileloop.py) INSTRUCTIONS: - Write while loop statements for the following.
🌐
Python Basics
pythonbasics.org › while-loop
Python "while" Loops (Indefinite Iteration) - Python Tutorial
Unlike a for loop, the iterator i is increased in the loop. Save then run with your Python IDE or from the terminal. You can also create infinite loops, this is when the condition never changes. In normal cases you want the program to exit the while loop at some point.
🌐
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 ...
🌐
Gitbooks
erlerobotics.gitbooks.io › erle-robotics-learning-python-gitbook-free › content › loops › exercises_loops.html
Exercises: Loops | Erle Robotics Learning Python GitBook Free
Write a function remove_duplicates that takes in a list and removes elements of the list that are the same.For example: remove_duplicates([1,1,2,2]) should return [1,2]. ... from random import randint # Generates a number from 1 through 10 inclusive random_number = randint(1, 10) guesses_left ...