+1 vote
int j=0;

int i=0;





asked Aug 17, 2015 in Computer Science - IT by Amrit (14 points)
edited Aug 18, 2015 by slow_learner | 203 views

2 Answers

0 votes

In the loop if you notice the value of j and i is initially 0 .

You could loop using :

for i in range(0, 5):                     #Loop statement with proper indention
    print "We're on time %d" % (x)        #printing value in x

Secondly if you need to check using if condition the syntax is below :

i =11               # Some value
if i % 2 == 0:      # modulus operator

         print 'ok'
else :
    print 'cannot divide'

Hope you are clear about the syntax in Python ,just give a try on online IDEs available .

Edit 1 :

Yes you can check with another variable using if condition after the for syntax.

More find at Python Doc

answered Aug 17, 2015 by slow_learner (1,492 points)
edited Aug 17, 2015 by slow_learner
0 votes
Can the for loop in python have different iterating variable and condition variable ?
answered Aug 17, 2015 by Amrit (14 points)
Well,this may not be an answer ,always edit comments with question..