Python Program To Demonstrate Increment And Decrement Operators

Write Python code to demonstrate increment and decrement operators

# WAP to demonstrate increment and decrement operators

# Normal ++, -- return error
# Increment in for loop can
for i in range(5):
    print(i)
# for decrement
print()
# Second argument in range for
# lower limit, -1 for decrement
for i in range(4, -1, -1):
    print(i)

Output:

0
1
2
3
4

4
3
2
1
0

<< Previous | Next >>


Leave a Reply

Your email address will not be published.