Code explanation

Hello everyone,

i don’t understand this code can someone explain,it is difficult for me,like how do they know that the answer will even be in a list

Thank you
Jagmeet

Have you tried breaking it down into a series of steps yet? That’s always a good place to start. If you’ve covered lists and looping before then each individual step should be familiar to you.

For example how does the variable j change throughout each step? Why not start with the first iteration of that loop and just work out line by line what each statement is doing (same for any nested loops).

How do nested for loops work

Thank you
Jagmeet

This is what I do when come up with something I don’t understand:

  • identify if there are unfamiliar concepts
  • if not, simplify into sections (like @tgrtim said :slight_smile: )

I like to open the terminal and just test out concepts when they are new to me (or when the technique the concept is used with is unfamiliar to me). This means stepping away from the original problem to just get one’s bearings with the tools.

Additionally, I like to keep a small daily regimen of coding challenges to keep my mind sharp and improve technique (even though I think I know it!). Even after years there’s wrinkles in basic concepts that I pick up this way and help me be a better rounded programmer.

2 Likes

Found the solution,Thank you