+ 16

SL problem 😭😭I want to get my python degree but 4 of 10 questions do not work correctly. I don't know why 😭😭

One of this simple questions My code x= int(input()) xx=x%2 if xx !=0: print(xx) if x % 3 == 0: print("Solo") if x % 5 == 0: print("Learn") elif x % 3 == 0 or x % 5 == 0: print("SoloLearn") Sololern 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.

10th Nov 2020, 9:44 AM
Donya Khoobani
Donya Khoobani - avatar
12 Respuestas
+ 12
Try this x = int(input()) for i in range(1, x,2): if i % 3 == 0 and i % 5 == 0: print("SoloLearn") elif i% 3 == 0: print("Solo") elif i % 5 == 0: print("Learn") else: print(i)
10th Nov 2020, 9:50 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 12
Your condition stmts with if else is wrong. It should be like: if ..... elif ...... else.....
10th Nov 2020, 9:47 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 9
Alphin K Sajan Ok Thanks
10th Nov 2020, 9:51 AM
Donya Khoobani
Donya Khoobani - avatar
+ 8
Alphin K Sajan You're code is true 👍👍👏👏👏 Thank you
10th Nov 2020, 9:54 AM
Donya Khoobani
Donya Khoobani - avatar
+ 8
Slick Thanks
10th Nov 2020, 10:15 AM
Donya Khoobani
Donya Khoobani - avatar
+ 8
Ajin I solved it Thanks
14th Nov 2020, 7:12 AM
Donya Khoobani
Donya Khoobani - avatar
10th Nov 2020, 9:51 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 6
Alphin K Sajan but my code working true It's showing correct answer but it's not accept by SL
10th Nov 2020, 9:50 AM
Donya Khoobani
Donya Khoobani - avatar
+ 6
Donya Khoobani Wlcm again
10th Nov 2020, 9:54 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
the first if check should be a check if its even, if so print the number. the second check should be if it's divisible by 3 AND 5 (you used OR), if so print SoloLearn - MAKE it an elif check! then afterwards check for being induvidually divisible by either 3 or 5
10th Nov 2020, 9:50 AM
Slick
Slick - avatar
+ 2
I think you ve got a problem on your mobile
19th Nov 2020, 3:09 PM
Rita Lakna
Rita Lakna - avatar
0
I am new in it what can i do for you
14th Nov 2020, 7:03 AM
Ajin