+ 1
Why would this be like this?
Basically i understand most of this i made it to kind of practice amd further understand it but when i put a=a+4 why would it not add the original a = 2 and 4 and begin counting by 6? https://code.sololearn.com/c3KdGxs52I10/?ref=app
18 odpowiedzi
+ 16
a = 2 # a is 2
print(a+2) # a is 2 but it prints 4
a = a+4 # a is 2+4 so a is 6
print(a+2) # a is 6 but it prints 8
a = a+4 # a is 6+4 so a is 10
print(a+2) # a is 10 but it prints 12
a = a+4 # a is 10+4 so a is 14
...
+ 16
Thanks for the Tick ✔ 👍
+ 15
Can you tell us what sequence you want?
Do you want 2,4,6,8... or 4,8,12.. or 6,10,14...?
+ 4
yea u made it pretty clear @Jafca. still have doubts @seth?
+ 3
ah ok. honest mistake. we are here to help
+ 2
"a" gets the value of a + 4. since "a" starts with 2, a gets the value of 2 + 4. so "a" gets the value of 6.
if u continue....
a=a+4 // a is 10
a=a+4 // a is 14
a=a+4 // a is 18
and so on
+ 2
oh lol im not sure
+ 2
oh
+ 2
cause you are printing a + 2. change it to just print a
+ 2
so you want to start at 4 and then count by 4s?
+ 2
but if its already counting by 4s, i dont understand your problem
+ 2
because then that would be counting by six. which means you would need a = a + 6.
+ 2
omg im dumb, the a+4 part just means its going to add a by 4, saying a = a+4 through me off because i assumed it would add that 4 to the a and count by the new a. thanks tho
+ 2
Yep thanks you guys!
+ 1
no see thats what im saying if you run the code it still counts by 4s not 6s
+ 1
but what if i want it to start at 4 without makimg a=4?
+ 1
exactly BUT without changing a=2 to a=4
+ 1
its not my problem, my problem is why doesnt a=a+4 not cause the original a to add with 4 and instead of counting by 4s count by 6s. sorry you kinda confused me, i want it to count by 4s and it does but why isnt it counting by 6s like it technically should. a+4 would be 2+4 which = 6 which means a would now = 6 therefore it shouldnt count by 4s anymore it should begin with 4 then continue to add with 6s.
4
10
16
22
...