+ 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)

18th Oct 2020, 8:31 PM
Shakhzod Yuldoshov
Shakhzod Yuldoshov - avatar
14 Answers
+ 11
Thank you so much. I is working
30th Oct 2020, 3:00 AM
Shakhzod Yuldoshov
Shakhzod Yuldoshov - avatar
+ 14
I use: for x in range(1,n,2): It skips the even numbers.
18th Oct 2020, 8:52 PM
Paul
Paul - avatar
+ 5
To skip the even numbers, I just put an extra if at the front(after for): if(x % 2 == 0): continue
3rd Nov 2020, 7:23 AM
Tanmoy Kumar Das
Tanmoy Kumar Das - avatar
+ 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)
14th Dec 2020, 11:24 PM
Bruno Coelho
Bruno Coelho - avatar
+ 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)
15th Feb 2021, 3:03 AM
ekkwnsnsnwkkqwknnq
ekkwnsnsnwkkqwknnq - avatar
+ 2
if you use 2 in the loof besid with n as aegument your project will inshallah be successfully completed
13th Dec 2020, 6:50 AM
Abdul Qayom Silab🇦🇫
Abdul Qayom Silab🇦🇫 - avatar
+ 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.
12th Aug 2021, 5:39 AM
Aaron
Aaron - avatar
+ 1
yes
25th Oct 2020, 11:15 PM
Роман Ф
Роман Ф - avatar
+ 1
i have a one-liner code for this, you can see it here : https://code.sololearn.com/cd5vqZMsf4p4
20th Mar 2022, 3:58 PM
İsa Mücahid
İsa Mücahid - avatar
+ 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)
16th Apr 2022, 11:46 AM
Dr. Steffen Lesle
0
Your mistake: for x in range (1,n,2) You should enter number 2 in this code,dude)
29th Dec 2020, 6:10 PM
MaryRif
MaryRif - avatar
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)
6th Jan 2021, 8:15 AM
Barbu Vulc
Barbu Vulc - avatar
0
how can i make it just for the solo learn when i reach a number that is divisible by 3 and 5?
22nd Oct 2021, 4:27 AM
Pau Klutz
Pau Klutz - avatar
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)
30th Jul 2022, 12:27 PM
Tushar Kumar
Tushar Kumar - avatar