To add to what Patrice has - rightly - said: indentation in Python is significant.
All code indented to the same level forms a single code block whioch only ends when a lesser level on indentation is found,
So this code:
For i in range(0,n+1):
if(i%6==0):
Continue
Sum=sum+i
print(int(sum))
print(sum)
Contains two code blocks inside the
for
loop, one nested inside the other. One code block is the
if
statement:
For i in range(0,n+1):
if(i%6==0):
...
print(sum)
The other is the content of the
if
which is only executed if the condition is true, and is executed in its entirety:
Continue
Sum=sum+i
print(int(sum))
Since the first instruction in that code block causes the
for
loop to immediately carry on with the next iteration ignoring all further code in the loop body, you get no sensible output.
As Partrice says: indent your code to multiple blocks:
For i in range(0,n+1):
if(i%6==0):
Continue
Sum=sum+i
print(int(sum))
print(sum)
And it'll do what you want.
Alternatively, reverse the test:
For i in range(0,n+1):
if(i%6 != 0):
Sum=sum+i
print(int(sum))
print(sum)
And you don't need the
continue
at all - which is more readable!