+ 13
Fizzbuzz
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") else: print(x)
14 Antworten
+ 11
Thank you so much. I is working
+ 14
I use:
for x in range(1,n,2):
It skips the even numbers.
+ 5
To skip the even numbers, I just put an extra if at the front(after for):
if(x % 2 == 0):
continue
+ 5
I finally solved the challenge on python tutorial. I am happy that I solved by myself without googling too too much. But now that I see the solution above from Tanmoy Kumar I think my code is too long...at least it solved it😂
n = int(input())
for x in range(1, n):
if x % 3 == 0 and x % 5 == 0:
print("SoloLearn")
elif x % 3 == 0 and not x % 2 == 0:
print("Solo")
elif x % 5 == 0 and not x % 2 == 0:
print("Learn")
elif not x % 2 == 0:
print(x)
+ 3
n = int(input())
for x in range(1, n):
if x % 2 == 1:
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)
+ 2
if you use 2 in the loof besid with n as aegument your project will inshallah be successfully completed
+ 2
I'm gonna have to get down on this fizzbuzz. I'm pretty sure that this is gonna be the point where I meet the most adversity before I understand.
+ 1
yes
+ 1
i have a one-liner code for this, you can see it here :
https://code.sololearn.com/cd5vqZMsf4p4
+ 1
You can also put an "if" statement at the beginning for startign the rest of the code for even numbers (just remember to intend the rest of the code).
for x in range(1, n):
if x % 2 != 0:
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
Your mistake: for x in range (1,n,2)
You should enter number 2 in this code,dude)
0
Bruno Coelho I tried something similar, but a bit different:
k = int(input())
for i in range(1, k):
if i % 3 == 0 and i % 5 == 0:
print("SoloLearn")
elif i % 3 == 0 and i % 2 != 0:
print("Solo")
elif i % 5 == 0 and i % 2 != 0:
print("Learn")
elif i % 2 != 0:
print(i)
0
how can i make it just for the solo learn when i reach a number that is divisible by 3 and 5?
0
you should first exclude the even numbers and the rest code will work fine
n = int(input())
for x in range(1, n):
if x % 2 == 0:
continue
elif x % 3 == 0 and x % 5 == 0:
print("SoloLearn")
elif x % 3 == 0:
print("Solo")
elif x % 5 == 0:
print("Learn")
else:
print(x)