Oct-26-2018, 07:06 PM
Learning 'for' loops and having trouble wrapping my head around this one:
I cannot figure out what line 4 is doing (what does "result * indx" actually do?). I know I'm missing something fundamental but my web searching hasn't yielded the information I need.
the value of result after running the program is 945.
Thanks in advance if you can point me in the right direction.
**I'm in a non-credit python programming class. the course is not graded and the instructor does not mind us getting help.
result = 1 for indx in range (10): if (indx % 2 == 0): continue result = result * indxI think I understand what lines 1-3 do.
- Line 1 assigns an integer to result object.
- Line 2 begins the for loop, calling upon the range function to generate a integer range 0-9.
- Line 3 is an if statement that says if the remainder of the indx divided by 2 is equal to 0, then skip the indx and continue to next value. This effectively skips all even integers.
I cannot figure out what line 4 is doing (what does "result * indx" actually do?). I know I'm missing something fundamental but my web searching hasn't yielded the information I need.
the value of result after running the program is 945.
Thanks in advance if you can point me in the right direction.
**I'm in a non-credit python programming class. the course is not graded and the instructor does not mind us getting help.