+ 1

Fizzbuzz problem

Can someone please help me? I enter this code; the output is similar to that produced by Sololearn, yet, something is improper, (it remains red). n = int(input()) for x in range(1, n): if x % 2 == 0: continue elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x)

18th Feb 2022, 9:23 PM
Catherine
4 Answers
+ 6
Read the task description carefully: You also need to check if a number is divisible by 3 AND 5
18th Feb 2022, 9:28 PM
Lisa
Lisa - avatar
+ 1
Consider the order of the condition: the 4th will never be reached because if number is divisible by 3 or 5 it will already "drop out" in the previous condition. That means you need to check your now 4th condition before you check divisibility by 3 and 5
19th Feb 2022, 8:36 PM
Lisa
Lisa - avatar
0
Catherine There is one more condition to print "Sololearn"
19th Feb 2022, 3:38 AM
A͢J
A͢J - avatar
- 1
Thank you for your advice. Including when I type this code, I only get the case #1 approved, (the 2nd case, for some reason, remains locked). n = int(input()) for x in range(1, n): if x % 2 == 0: continue elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") elif x%5 == 0 and x%3 == 0: print("SoloLearn") else: print(x)
19th Feb 2022, 8:32 PM
Catherine