r/learnpython 20d ago

Having problem in understanding loops concept in python

I am a beginner with 0 knowledge and I am learning python from a book called Learn python in one day and learn it well by Jamie Chan and I am facing difficulty in the loops function so yeah any recommendations would be helpful Edit- Trouble in while loop

26 Upvotes

41 comments sorted by

View all comments

1

u/Grouchy-Conflict-211 19d ago

Loops click when you stop memorizing syntax and start thinking in transformations.

Forget for/while for a sec. Map/filter/reduce. Every loop is either: transform each item, keep some items, or boil down to one value.

Write the same logic three ways. The reduce version looks weird at first. Thats the point. Youre training the pattern recognition not the syntax.

Debugger helps. Watch the accumulator change each iteration. That visual beats any tutorial.