If you’re familiar with Python, you would have known Increment and Decrement operators ( both pre and post) are not allowed in it.
Python is designed to be consistent and readable. One common error by a novice programmer in languages with ++ and -- operators is mixing up the differences (both in precedence and in return value) between pre and post increment/decrement operators. Simple increment and decrement operators aren’t needed as much as in other languages.
You don’t write things like :
for (int i = 0; i < 5; ++i)
In Python, instead we write it like
0 1 2 3 4
We can almost always avoid use of ++ and --. For example, x++ can be written as x += 1 and x-- can be written as x -= 1.
This article is contributed by Harshit Gupta. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Python 3 basics
- Inplace vs Standard Operators in Python
- How to check if a string is a valid keyword in Python?
- Operator Functions in Python | Set 1
- Any & All in Python
- Partial Functions in Python
- Ternary Operator in Python
- Loops and Control Statements (continue, break and pass) in Python
- Python | end parameter in print()
- Important differences between Python 2.x and Python 3.x with examples
- Division Operators in Python
- Python | Set 2 (Variables, Expressions, Conditions and Functions)
- Python Language Introduction
- G-Fact 19 (Logical and Bitwise Not Operators on Boolean)
- Python – The new generation Language