r/learnpython • u/21bce • Jul 31 '22
Loops in python are weird
I recently started learning python programming. I also had some exposure to programming in my high school.
Today I studied loops but I found them a little bit weird...they do not have any initialisation, condition and increment like other languages like javascript.
It is very confusing to me PLEASE HELP!!
0
Upvotes
6
u/[deleted] Jul 31 '22
Python (and many more modern languages that aren’t tied to 60-year-old C concepts) figure that the only reason you’re counting up an index variable from 0 was to access the elements of a collection anyway, so just… do that. Yield the elements of a collection in order.