+ 2

Python code fizz buzz

I think the descrition or the solution is not correct. It sais fir each number which is a multiple of 3 the word solo should be printed but when it gets to number 6 which is a multiple of 3 in my understanding nothing should be printed acc requested output

27th Oct 2020, 5:05 PM
Pál Zsuzsanna
6 Respostas
+ 2
n = int(input()) for sololearn in range(1,n,2): if sololearn % 3 == 0 and sololearn % 5 == 0: print('SoloLearn') continue elif sololearn % 3 == 0: print('Solo') continue elif sololearn % 5 == 0: print("Learn") continue print(sololearn) #there is an error in all ans. #in second line (the for loop), but its now resolved.
21st Apr 2021, 9:28 AM
Shivankur Sharma
Shivankur Sharma - avatar
0
n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0 and x != 6 and x != 12: print("Solo") elif x % 5 == 0 and x != 10: print("Learn") else: if not x % 2 == 0 : print(x)
25th Feb 2021, 10:20 PM
Vahid Amini
Vahid Amini - avatar
0
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)
24th Apr 2021, 9:31 AM
Faramarz Kowsari
Faramarz Kowsari - avatar
0
n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 2 == 0: continue elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x) By using elif x % 2 == 0 we can skip the even values ranging from 1 to n. It will skip the even values and then further go for next line elif statements.
6th May 2021, 5:37 AM
Kiran Kavire
Kiran Kavire - avatar
- 1
my code is: n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") elif not x%3==0 or x%5==0: print(x) continue I think the answer presents mistake?
15th Nov 2020, 12:32 AM
YANG Fei
YANG Fei - avatar
- 2
It's because 6 is an even number.
27th Oct 2020, 11:55 PM
Max Harder
Max Harder - avatar