+ 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
6 ответов
+ 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.
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)
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)
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.
- 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?
- 2
It's because 6 is an even number.