if statement inside while loop

Don't have an answer for you here , just a suggestion that may help.I was having many issues with code understanding and found a site that really helped me .Top Tech Boy has online videos that help understand some of these issues ,hope this helps somewhat.