0

Solve FizzBuzz problem?

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.

3rd Aug 2021, 6:38 AM
Raghvendra Pratap Verma
Raghvendra Pratap Verma - avatar
2 Respostas
+ 4
Hi Raghvendra! Usually, FizzBuzz challenges are pretty cool and interesting! In order to solve this problem, you have to use multiple if-else statements and modulo operator inside a loop. First, you can declare n as input to take inputs from the users. Multiple of 3 means n%3==0, for 5 n%5==0 and for 15 both 3 and 5 should give reminder as 0( n%5==0 and n%3==0). There are many ways to skip the even numbers. I give you some examples below. 1. for i in range(1,n,2) 2. for i in range(1, n): if i % 2 == 0: continue
3rd Aug 2021, 8:21 AM
Python Learner
Python Learner - avatar
+ 2
Thanks python learner
3rd Aug 2021, 8:35 AM
Raghvendra Pratap Verma
Raghvendra Pratap Verma - avatar