- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Increment and Decrement Operators
In this article, we will learn about increment and decrement operators in Python 3.x. Or earlier. In other languages we have pre and post increment and decrement (++ --) operators.
In Python we don’t have any such operators . But we can implement these operators in the form as dicussed in example below.
x=786 x=x+1 print(x) x+=1 print(x) x=x-1 print(x) x-=1 print(x)
787 788 787 786
Other languages have for loops which uses increment and decrement operators. Python offers for loop which has a range function having default increment value “1” set. We can also specify our increment count as a third argument in the range function
for i in range(0,5): print(i) for i in range(0,5,2): print(i)
0 1 2 3 4 0 2 4
In this article, we learned how to use Increment and Decrement Operators in Python.
- Increment and Decrement Operators in Python?
- PHP Increment/Decrement Operators
- Increment and decrement operators in Java
- Increment and Decrement Operators in C#
- Increment ++ and decrement -- Operators in C++
- What are increment (++) and decrement (--) operators in C#?
- Interesting facts about Increment and Decrement operators in Java
- What are the restrictions on increment and decrement operators in java?
- Increment ++ and Decrement -- Operator Overloading in C++
- Pre-increment (or pre-decrement) in C
- Write a C program to demonstrate post increment and pre increment operators
- Count of suffix increment/decrement operations to construct a given array in C++
- Pre-increment and Post-increment in C/C++