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 i += 1 is not the same what you expected i++ to do. Integers are immutable in Python. With i += 1 you create a new integer behind the scenes.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.
i +=1++in a python program.