Login using Social Account
     Continue with GoogleLogin using your credentials
When it comes to updating the existing variable, we need to re-assign it after updating its value,
a = a + 1
It gets the current value of a
, adds 1
, and then updates a
with the new value.
If we try to increase or decrease the value of a variable that is not yet assigned any value i.e. it doesn't exist, you get an error, because Python evaluates the right side before it assigns a value to a
.
Therefore, before increasing or decreasing the value, we need to initialize the variable,
a = 0
a = a + 1
a = a - 1
a = a * 2
a = a // 3
Try updating a random variable which hasn't been initialized and observe the error.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...