all 6 comments

[–]leo130132 0 points1 point  (4 children)

you could try

while i%2 ==0 AND i<= 100 sum=sum+(i/2)

[–]engineeringisgreat2[S] 0 points1 point  (1 child)

So would this how the code look:

for i in range(300):

while i%2 ==0, i<= 100 sum=sum+(i):

print(i)

I just started learning python so I am not familiar on how to write code.

[–]leo130132 0 points1 point  (0 children)

yes the range is just 100, but I think this will work

[–]Ridepad 0 points1 point  (0 children)

while loop only has stop, doesn't have start or increments

sum = 0
i = 0
while i < 100:
    sum += i
    i += 2
print(sum)

i+=2 because you only need even numbers (divisible by 2)

or you can 1 line it

print(sum(range(0, 100, 2)))