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 ?

27th Jun 2018, 6:04 AM
Ahmed
Ahmed - avatar
3 ответов
+ 5
x=30 you can say x+=15 //x is now 45 you can change the variables value without recalling/reusing the variable
27th Jun 2018, 6:06 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
You can also assign new var to keep the value. y = x+15
27th Jun 2018, 6:50 AM
Qwertiony
Qwertiony - avatar
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
27th Jun 2018, 6:17 AM
Ahmed
Ahmed - avatar