Behaviour of increment and decrement operators in Python

In Python, the increment operator (++) and decrement operator (--) do not exist. Instead, you can use the += and -= operators to increment or decrement a variable by a specific value. For example:

# increment a variable by 1
x = 5
x += 1
print(x)  # Output: 6

# decrement a variable by 1
y = 10
y -= 1
print(y)  # Output: 9

# increment a variable by any value
z = 20
z += 5
print(z)  # Output: 25

# decrement a variable by any value
w = 50
w -= 10
print(w)  # Output: 40

Watch a course Python - The Practical Guide

Note that these operators can be applied to any number variables, including floats and negative numbers.

Also python have x +=1 can be written as x=x+1 and x -=1 as x=x-1