[Solved] for loop and lists, new to python and programming [closed]


If you use VSCode or Pycharm you have Debug option to understand what is happening in each step. Let’s debug it:

a = 4

  • first loop:

    x = 3 and it’s add to a variable that was 4, so a = 4 + 3 and now a = 7

  • second loop:

    x = 4 and it’s equal to 4, so it’s add to a variable that was 7, so a = 7 + 4 and now a = 11

  • third and fourth loop:

    x = 5 and x = 6 and they are smaller than 4, so nothing happen.

and finally a is 11

1

solved for loop and lists, new to python and programming [closed]