Increment By 1 In Python

Python provides different methods and operators to increase integer variables by 1. The increment by 1 is very useful to iterate over a list of values. In this tutorial, we examine how to increment by 1 in Python in detail.

Increment Operator

The most popular method to increment by 1 is the increment operator . The increment operator is expressed as += which simply sums the left side variable with the right side provided value. If we provide the value as 1 the left side variable is incremented by 1. The syntax of the increment operator to increment by 1 is like below.

VARIABLE +=1
  • VARIABLE is incremented by 1.

In the following example, we increment the variable named age 1 by 1.

age = 18

age+=1

print(age)

Sum Operator

Like all programming languages, Python provides the sum operator. We can simply use the sum operator in order to increment by 1. Incrementing by 1 is easier to read if implemented with the sum operator. In the following example, we simply sum the “age” variable with 1.

age = 18

age = age+1

print(age)

Leave a Comment