0

How can a write a FizzBuzz program in Python?

2nd Nov 2020, 12:45 PM
Devansh Jhawar
Devansh Jhawar - avatar
11 Answers
+ 2
Devansh Jhawar Ok so here's the code: n = int(input("Enter the ending number: ")) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("FizzBuzz") elif x % 3 == 0: print("Fizz") elif x % 5 == 0: print("Buzz") Hope It helps :) If you have any queries, feel free to ask...
3rd Nov 2020, 7:07 PM
Advik
Advik - avatar
+ 1
Khalid Kotte Why is there a continue statement?? There's no Loop in the code! Continue & break statement is used only when in a Loop!!
1st Jan 2021, 5:31 PM
Advik
Advik - avatar
+ 1
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)
18th Mar 2021, 12:27 PM
Anointing Izuchukwu
Anointing Izuchukwu - avatar
0
Search the web dude, if you don't wanna write yourself!!!
3rd Nov 2020, 4:26 PM
Advik
Advik - avatar
0
I'd tried it from days and I'm not getting it right so I'm asking for a help. A small hint would be a great help bro.
3rd Nov 2020, 6:22 PM
Devansh Jhawar
Devansh Jhawar - avatar
0
Thanks a lot ADVIK for the answer. It truly helped me. I got to know where I was making mistake. Thank you once again
4th Nov 2020, 12:23 AM
Devansh Jhawar
Devansh Jhawar - avatar
0
Help me to solve this quiz, it tells me "expected an indented block in line 5"
17th Dec 2020, 2:27 PM
Khalid Kotte
Khalid Kotte - avatar
18th Mar 2021, 6:12 PM
Swaroop Kumar Badugu
Swaroop Kumar Badugu - avatar
0
30th Apr 2021, 2:25 AM
Aditya Panigrahy
Aditya Panigrahy - avatar
- 2
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) #This is the correct answer
30th Apr 2021, 2:25 AM
Aditya Panigrahy
Aditya Panigrahy - avatar
- 3
print('Enter a number') n=int(input()) for SoloLearn in range(1,n): if ((SoloLearn % 3)==0)and (SoloLearn %5)==0): print("SoloLearn") continue elif SoloLearn %3==0: print("Solo") continue elif SoloLearn %5==0: print("Learn") else: print("SoloLearn")
17th Dec 2020, 2:26 PM
Khalid Kotte
Khalid Kotte - avatar