I'm confused about the iteration process in python
I have:
numbers = [0,1,2,3,4,5]
for i in numbers:
v = numbers
print v
Here is the end of loop
but, in C , C++ , Java we know the line inside the { } will be executed repeatedly, or if not given curly braces then the next statement after the loop, but I'm confused here.
How many lines will be executed in the iteration?
Does it depend on indent?
In Python, the indentation, rather than brackets, determines block scope, so in this example both the indented lines will be executed once per iteration of the loop.
This is the single weirdest thing about Python for programmers coming from the C/Java language families, but you get used to it fairly quickly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With