0
Please, I need solution for 30 project(FizzBuzz) in python
https://code.sololearn.com/cWB3R3j6Mqar/?ref=app Question: FizzBuzz is a well known programming assignment, asked during interviews. The given code solves the FizzBuzz problem and uses the words "Solo" and "Learn" instead of "Fizz" and "Buzz". It takes an input n and outputs the numbers from 1 to n. For each multiple of 3, print "Solo" instead of the number. For each multiple of 5, prints "Learn" instead of the number. For numbers which are multiples of both 3 and 5, output "SoloLearn". You need to change the code to skip the even numbers, so that the logic only applies to odd numbers in the range.
15 Respuestas
+ 9
I got the solution. The correct code is:
https://code.sololearn.com/c73fF7Zjde64/#py
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)
+ 8
Please attach your code so we can help!
+ 6
Remove the lines 2 and 12 – you neither need while nor continue
+ 3
Arsenic "learn"? People don't come here to learn. They come for the xp, levels, badges, views, upvotes, and followers.
+ 2
Your code works as expected but you haven't implemented the odd/even condition yet (last paragraph of the task description)
+ 2
n=int(input())
for i in range(1,n):
while i<n:
if i%2==0:
break
if i%3==0 and i%5==0:
print("SoloLearn")
break
elif i%5==0:
print("Learn")
break
elif i%3==0:
print("Solo")
break
else:
print(i)
break
+ 1
I am confused where to use the while-continue loop
+ 1
i have same problem with fizz buzz, when i change x%3==0 to x%3==2, it can solve first question, but not second question. And when i change x%5==0 to x%5==3, it can solve second question but not third question. Then it continue until i feel so headache.
+ 1
here is the answer... this could help...
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)
0
No error but desired output is not coming
0
Bmi calculator many more mistake so please can you send the answer
0
n = int(input())
for x in range(1, n):
while x < n :
if x % 3 == 0 and x % 5 == 0:
print("SoloLearn")
elif x % 3 == 0:
print("Solo")
elif x % 5 == 0:
print("Learn")
if x % 2 == 0 :
continue
else:
print(x)
I tried this but it didn't work out is there something else i can try or is there just wrong with my syntax
I also tried using elif instead of if but i had a similar problem. It said 'continue' does not fit in the loop
- 1
And I need to know, how will providing you the solution of the questions help you learn ?
- 2
test case 1 is execute but test case 2 dose not run error