0
How can a write a FizzBuzz program in Python?
11 ответов
+ 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...
+ 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!!
+ 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)
0
Search the web dude, if you don't wanna write yourself!!!
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.
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
0
Help me to solve this quiz, it tells me "expected an indented block in line 5"
0
Thanks Devansh Jhawar
0
- 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
- 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")