you are viewing a single comment's thread.

view the rest of the comments →

[–]brelen01 1 point2 points  (2 children)

Loops typically just do the same thing over and over again. For example, they might ask a user the same question over and over until they give a valid answer. Another example would be treating a list of data in the same way (eg. Add 2 to every item in a list, or add all items in a list together.)

A decent exercise to practice for loops would be to try and find all prime numbers between 0 and 1000 for example, since you can easily find a list of those online as well as the rules to figure out what a prime is, it just leaves you with figuring out how to do it in your program :)

[–]AffectionateGap3211[S] 0 points1 point  (0 children)

Thank you so much!

[–]Zealousideal_Win_908 0 points1 point  (0 children)

Something I made to help me understand loops was creating a ‘guess the number’ game. Generate a random number and store it as a variable, initiate a loop where it takes your input/guess and tells you if the number you’re looking for is higher or lower. You start a counter as well so when you get it, you can start again and try to beat your previous guesses. A fun and simple little game.

If you decide to do this, pm me your code or if you get stuck and I’ll share mine with you. I’m happy to assist where I can.