+ 1

How do i declare a variable

I was tasked with declaring a variable and to add 5 to it but am finding it really difficult. i just started today. here is the code below x=4 x_=5 print___

27th Jan 2018, 8:52 AM
Elex Promise
Elex Promise - avatar
4 Answers
+ 9
x=4 x+=5 print(x)
27th Jan 2018, 10:06 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
x=0 x=x+5
27th Jan 2018, 8:55 AM
shobhit
shobhit - avatar
+ 1
writing one extra x is just redundant. x+=5 is same as x=x+5. and no it wouldn't continue grow because you are doing it only once
29th Jan 2018, 8:54 AM
shobhit
shobhit - avatar
0
Question on the answer. Why would you use that same variable name? if you do x=x+5, wouldn't that continue to just grow? x=value y=value+5 print(y) I am sure my logic is flawed, so any explanation would be appreciated.
28th Jan 2018, 6:54 PM
K.C. Christensen
K.C. Christensen - avatar