I cant use i++
in python. My code is
i=0
while i<10:
print i
i++
But it works fine if I replace i++
with i=i+1
it works. What have I done wrong
I cant use i++
in python. My code is
i=0
while i<10:
print i
i++
But it works fine if I replace i++
with i=i+1
it works. What have I done wrong
There is no ++ operator in python. You must use
i += 1
It's just that i++
isn't supported in python. Replace that loop as follows:
i=0
while i<10:
print i
i += 1 # add 1 to i.
Or, even better (in case you are indeed using loops that way):
for i in range(0, 10):
print i
Please take a look here for a list of all operators.