Last answered:

27 Oct 2021

Posted on:

30 May 2021

0

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)
Posted on:

26 Oct 2021

0

use count = count +1 to increment, shorthand operators  += can be used too

Posted on:

27 Oct 2021

0

You can use the for loop and range function in Python:

for i in range(0, 10):
    # do something

Submit an answer