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.comPython while loop (coding exercise, three variables) - Stack Overflow
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.comFor 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.comVideos
I'm looking for projects that can help me practice for and while loops:
So far, I have mastered if statements, operators, and all the simple stuff, however, I have been struggling with loops for some time. I figure some practice projects could help me get the hang of it.
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.
It's hard to imagine any kind of program that wouldn't contain a loop; it's a pretty essential concept in the programmer's toolkit.
So really any project will make you write for loops. (Don't worry about while, it's actually used quite a bit less in Python.)
But I think better than practice is understanding. If you understand what for does then the conditions under which you should use it are pretty obvious.
Your loop currently loops until any of the numbers is less than or equal to zero. Said out loud, your loop is "while mystery_int_1 isn't less than or equal to zero and mystery_int_2 isn't less than or equal to zero and ...", so if any of them is less than or equal to zero, the loop stops.
You want this:
while not (mystery_int_1 <= 0 and mystery_int_2 <= 0 and mystery_int_3 <= 0):
Or this:
while mystery_int_1 > 0 or mystery_int_2 > 0 or mystery_int_3 > 0:
Or possibly this, though I find this version the most confusing. (That said, it's closest to what you already have.)
while not mystery_int_1 <= 0 or not mystery_int_2 <= 0 or not mystery_int_3 <= 0:
try this -
while not mystery_int_1 <= 0 or not mystery_int_2 <= 0 or not mystery_int_3 <= 0:
mystery_int_1 -= 1
mystery_int_2 -= 1
mystery_int_3 -= 1
print("{} {} {}".format(mystery_int_1, mystery_int_2, mystery_int_3))
Read python and AND `or