You are here: Home / Topics / Increment and decrement operator in python

Increment and decrement operator in python

Filed under: Python on 2022-08-31 16:20:51

In other programming language like C,C++, JAVA, we have a increment(++) and decrement(--) operator which increase and decrease the value respectively.

example -

a=3
a++
a will become 4
a--
a--
a will become 2

-But in python this type of operation is not valid


program -

a=3
a++
print(a)
a--
a--
print(a)

output-
 

a++
^
SyntaxError: invalid syntax
 


- In Python, this operator is not supported that's why it will give the error like invalid syntax.

About Author:
Y
Yogesh     View Profile
I am Yogesh Sharma. I found this website very useful for all the students. It is a very good website for learning thousands of multiple choice questions. Basically it is like a community website. Everyone can add questions so am I. I will add mcqs in this website to help you.