0
Is there a way to increase a value of a variable other than rewriting it ?
I was wondering if you can increase a value (number) in a variable without completely replacing it ? I know that sounds kind of pointless and dumb but I'm just curious for example, my_exp = 50 and I want to increase that by 15, but I don't want to do my_exp = 65 is there another way or am I being dumb over here ?
3 Answers
+ 5
x=30
you can say
x+=15
//x is now 45
you can change the variables value without recalling/reusing the variable
+ 1
You can also assign new var to keep the value.
y = x+15
0
Oh my, thank you !
I was trying that but it wasn't working so I thought I was doing something wrong and made this post, but now I realised that after updating/changing/increasing the value I have to write new Print commands in lines under it instead of relying on ones above it to view its current value