0

Fizz Buzz (Not able to solve) Guide me.

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.

13th Oct 2021, 7:09 PM
Sandeep Durge
Sandeep Durge - avatar
6 Réponses
+ 5
Hello, can we see your attempt first? Whats the point of knowing the answer if you cant solve it yourself? What if an interviewer really used problem for you, would you be able to solve it
13th Oct 2021, 7:46 PM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
+ 4
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)
7th Jan 2022, 9:36 PM
Jason Janis
+ 1
Thank you MD. Ferdous Ibne Abu Bakar for saving my practice time and guiding me the right answer.
14th Oct 2021, 12:31 AM
Sandeep Durge
Sandeep Durge - avatar
0
Jibraeel Abdelwahhab Thank you for inspiring me. I will try solving it myself. And will share my attempt if I am not able solve it.
13th Oct 2021, 7:50 PM
Sandeep Durge
Sandeep Durge - avatar
- 1
Welcome 🤗🥰
14th Oct 2021, 1:10 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
- 2
#Try this: n = int(input()) for x in range(1, n): if x % 2 == 1: 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)
14th Oct 2021, 12:22 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar