+ 1

How to solve this using

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. Code: n = int(input()) for x in range(1, n): 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)

18th Jul 2021, 3:28 PM
Jay Bhamare
Jay Bhamare - avatar
4 Answers
+ 1
Answer of this question: . . 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)
20th Jul 2021, 2:49 PM
Jay Bhamare
Jay Bhamare - avatar
+ 2
It does you no good if we just give you the answer, if you tried, please show us your code so we can show you were you went wrong
18th Jul 2021, 3:55 PM
Brain & Bones
Brain & Bones - avatar
0
Jay Bhamare How about using the 'continue' keyword?
20th Jul 2021, 2:35 PM
Calvin Thomas
Calvin Thomas - avatar