- 2
How can I avoid printing the even numbers in a python code,I'm in project 3,fizzy bus and I'm stuck
How do I solve it
17 Antworten
+ 4
SANNI ABDUL-AMEEN OLUWADARASIMI you are cheking for parity in a seperate loop, how do you expect it to work ?
Here is the fix👇
https://code.sololearn.com/c2nKcLNIkZ27/?ref=app
+ 3
if number % 2 == 0:
continue
+ 2
Thanks
+ 1
Try setting your range to skip the even numbers, then iterate.
n = int(input())
for x in range(1, n, 2):
if x % 3 == 0 and x % 5 == 0:
print("SoloLearn")
elif x % 3 == 0:
print("Solo")
elif x % 5 == 0:
print("Learn")
else:
print(x)
+ 1
Thank you
+ 1
Use continue for even condition
0
It didn't work
0
I have tried it before
0
This was my code
for x in range(1,n)
if x % 2 == 0:
continue
0
And I also tried break,none worked
0
Yes,but I used continue instead of pass
0
And all didn't work
0
Steven M,your code is wrong
0
Check Arsenic's
0
I almost got it,just a little bug
0
It doesn't,enter 15 and see the results