Python Forum
beginning python help request (for loop)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginning python help request (for loop)
#2
on line 4 current value of result is multiplied by current value of indx (that is right-hand side of the equal sign) and the result is assigned as new value of result
maybe if you add two print functions it will help
result = 1
for indx in range (10):  
    if (indx % 2 == 0):
        continue # I moved this on separate line just for more redability
    print('result before multiplication: {}, indx: {}'.format(result, indx))
    result = result * indx
    print('result after multiplication: {}'.format(result))
Note that you may see something like this
result *= indx
This is the same, but written a bit shortly
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
beginning python help request (for loop) - by casey - Oct-26-2018, 07:06 PM
RE: beginning python help request (for loop) - by buran - Oct-26-2018, 07:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginning Payroll code help EmRandall 6 9,093 Sep-18-2018, 01:21 AM
Last Post: EmRandall
  class and objects beginning python 3 pangea 2 3,171 Dec-15-2017, 12:35 PM
Last Post: mpd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020