+ 1

FizzBuzz is a well known programming assignment, asked during interviews. The given code solves the FizzBuzz problem and uses

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.

3rd Feb 2022, 7:00 AM
Ameen
7 Answers
+ 5
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)
12th Mar 2022, 6:56 AM
Abhishek Kumar
Abhishek Kumar - avatar
+ 2
Ameen Here is the code. Follow it and enjoy your learning n = int(input()) for x in range( n): if x%3 == 0 and x%5 == 0 and x%2 != 0: print ("SoloLearn") elif x%3 == 0 and x%5 == 0 and x%2 == 0: continue elif x%3 == 0 and x%2 == 0: continue elif x%3 == 0: print("Solo") elif x%5 == 0 and x%2 == 0: continue elif x%5 == 0: print("Learn") elif x%2 == 0: continue else: print("x") I hope u helpful it.
4th Feb 2022, 7:02 PM
Abdulatif Mohamednor Mohamed
Abdulatif Mohamednor Mohamed - avatar
0
n=int(input()) for i in range(1,n+1,2): if(i%15==0): print("SoloLearn") elif(i%5==0): print("Learn") elif(i%3==0): print("Solo") else: print(i)
3rd Feb 2022, 7:04 AM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
0
G'day Ameen how have you gone with the Python course so far? Is it all making sense? What have you tried for FizzBuzz (SoloLearn)? What sort of math could you use for: 3, 5, both 3&5? You could just copy someone else's code, but you won't learn that way, so try to do it yourself !
3rd Feb 2022, 7:30 AM
HungryTradie
HungryTradie - avatar
0
Great work Adi Nath Bhawani
3rd Feb 2022, 7:31 AM
HungryTradie
HungryTradie - avatar
0
Ameen Can't help you without seeing your try. Post it here or edit it in the question (and alert us). https://www.sololearn.com/discuss/1316935/?ref=app
3rd Feb 2022, 7:46 AM
NEZ
NEZ - avatar
- 1
Here the code n = int(input()) for x in range(1, n, 2): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") continue elif x % 3 == 0: print("Solo") continue elif x % 5 == 0: print("Learn") continue else: print(x)
13th Sep 2022, 1:22 PM
Saad Alhuthali
Saad Alhuthali - avatar