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.

24th Oct 2021, 7:24 AM
Shlok
Shlok - avatar
15 Antworten
+ 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)
1st Nov 2021, 6:55 PM
Shlok
Shlok - avatar
+ 8
Please attach your code so we can help!
24th Oct 2021, 7:44 AM
Lisa
Lisa - avatar
+ 6
Remove the lines 2 and 12 – you neither need while nor continue
25th Oct 2021, 7:18 AM
Lisa
Lisa - avatar
+ 3
Arsenic "learn"? People don't come here to learn. They come for the xp, levels, badges, views, upvotes, and followers.
24th Oct 2021, 6:59 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Your code works as expected but you haven't implemented the odd/even condition yet (last paragraph of the task description)
25th Oct 2021, 7:29 AM
Lisa
Lisa - avatar
+ 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
13th Sep 2022, 8:33 AM
Santosh Alimkar
Santosh Alimkar - avatar
+ 1
I am confused where to use the while-continue loop
25th Oct 2021, 7:15 AM
Shlok
Shlok - avatar
+ 1
Shlok the range function has a third argument, the step. If you don't specify it python uses the default value 1. Change it to skip even numbers. (There are other ways to achieve this.)
25th Oct 2021, 7:23 PM
Simon Sauter
Simon Sauter - avatar
+ 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.
16th Jun 2022, 1:20 PM
Novian Abimanyu
Novian Abimanyu - avatar
+ 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)
18th Sep 2022, 10:27 AM
Abdulhakim KARADENIZ
Abdulhakim KARADENIZ - avatar
0
No error but desired output is not coming
25th Oct 2021, 7:22 AM
Shlok
Shlok - avatar
0
Bmi calculator many more mistake so please can you send the answer
8th May 2022, 2:40 PM
T .Narmatha Narmatha
T .Narmatha Narmatha - avatar
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
30th Aug 2022, 12:47 AM
David Adeyemo Adeoluwa
David Adeyemo Adeoluwa - avatar
- 1
And I need to know, how will providing you the solution of the questions help you learn ?
24th Oct 2021, 7:26 AM
Arsenic
Arsenic - avatar
- 2
test case 1 is execute but test case 2 dose not run error
11th Jul 2022, 3:07 AM
Satyam Kumar