7

I often require doding a simple 1 unit incrementation (++) in Python.

I never seem to find a better solution than

x = x + 1 

What am I doing wrong ?

1
  • 6
    What you are doing wrong is expecting Python to be C. Commented May 29, 2012 at 18:37

2 Answers 2

20

Python doesn't have a ++ operator. You should use the += operator:

x += 1 
Sign up to request clarification or add additional context in comments.

Comments

5

The answer you are looking for is:

x += 1 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.