How to Add a Variable to Itself in Python
Adding a variable to itself is extremely common in all programming languages, including the Python programming language. One of the more common situations where this is required is when you are using a variable to keep count inside of a "for" or "while" loop, when you want to add the variable to itself to increase the count every time the loop executes.
Instructions
-
-
1
Open your Python application.
-
2
Locate the portion of the file where you want to add a variable to itself.
-
-
3
Type "$variable +=$variable;" onto the line where you want to add the "$variable" variable to itself to perform the operation.
-
1