How to Increment in Python
Python does not have any built-in increment(both pre and post) operator like any other programming languages.
In Python, you can increase the value of a variable by 1
using the augmented assignment operators. The code value += 1
increments the numeric values in value
by 1
.
>>> 34 34 >>> 34++ File "<stdin>", line 1 34++ ^ SyntaxError: invalid syntax >>> ++34 34 >>> value = 34 >>> value ++ File "<stdin>", line 1 value ++ ^ SyntaxError: invalid syntax >>>value +=1 >>>value 35
Subscribe
Login
Please login to comment
0 Discussion