I am trying to understand use cases for each type of loop. I was recently working on the Profile Lookup challenge, and had everything correct, but was using a While loop. The While loop got me an answer of “No such contact” everytime - the basic catch-all return value at the end of the function - no matter what variables where fed in. When I went to research, I found that the answer involved a for loop. So, I switched my while loop to a for loop and it worked. Without picking apart the program, I would like to know if there are specific use cases for each, as they seem like very similar looping to me (though a for loop seems to be more efficient).
I guess I am asking if there’s a fundamental difference between the loops that would cause someone to use one over the other in different situations.
Thank you so much to this community! I couldn’t do this without you!