For loop syntax unable to understand
Hi,
I am very much new to python and I am not able to clearly understand how for loop works. I have experience with C++ and which is why I am unable to relate pretty well.
For instance,
for(int i=0; i<10; i++)
and I am also unable to use the incremental operators in python. Like,
Count = 0;
while(condition) {
count ++;
How can the same loop be re-written in Python?
Regards,
Archie
2 answers ( 0 marked as helpful)
use count = count +1 to increment, shorthand operators += can be used too
You can use the for loop and range function in Python:
for i in range(0, 10):
# do something