Hey there, guys. Very first time doing any type of coding, literally started watching videos yesterday. So this is a very basic problem.. I've used google to try and find the answer to my woes but I can't find anything. The problem is with the code below - Instead of going to my 'for' loop, it immediatly bipasses it and head to the "You've won!"
As for an explanation of why it bypassed the for loop, here are the elements that cause the problem:
1 2 3 4 5 6 7 8 9 10
int a;
int b = (a = 7); //a and b are both 7 now, because (a = 7) returns a, thus b = a;
if(0){} //this condition is the same as if(false)
if(1){}
if(2){} //these three are the same as if(!false) or if(true)
if(3){}
for(; lives = 0;){} //because "lives = 0" returns lives, and lives is 0, the condition is false
//thus, the loop doesn't even run once.
@L B Don't understand why that's a problem. Probably don't know one of the basic rules I suppose..? Surely it's not a problem to tell the For loop to stop if lives is 0 or False?
Possible for you to give a example of a way to fix this?
Brilliant. Perfecto. Thanks alot, I had it in my head that it exited the loop on the requirements of that middle section rather than staying in. Vastly appreciated.