+ 1
Why the second test is failing ['SOLVED']
19 Respuestas
+ 5
your code is also working. just instead of the right phrase SoloLearn, you wrote Sololearn. this is also important
+ 4
You will need to use two range for solving. Showed below:
# for x in range(1, n,2): [correction in code needed]
By using this approach also, you can solve it. However, you will need to take 2 range. Without range 1, n, 2 (won't get solved) 👇
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)
+ 4
Ярослав Вернигора(Yaroslav Vernigora)
While solving I took reference from here:
Python's range() Parameters
The range() function has two sets of parameters, as follows:
https://www.pythoncentral.io/pythons-range-function-explained/
It has shown, how ranges works in conditioned for loops
range(stop)
stop: Number of integers (whole numbers) to generate, starting from zero. eg. range(3) == [0, 1, 2].
range([start], stop[, step])
start: Starting number of the sequence.
stop: Generate numbers up to, but not including this number.
step: Difference between each number in the sequence.
---------------
So, to skip even numbers in code... when we already have multiplie by 3 & 5.
We usually do even number with multiple of 2. This way, my problem was solved.
For increments we usually do something like "range(1, n+1)". I did it using [2 as step] in for loop.
Start with 1
Stop with n (input)
Step by using 2
+ 3
Thank you so much
Ярослав Вернигора(Yaroslav Vernigora)
I am so stupid lol 😆🙃😂
+ 1
བསོད་ནམ་བཀྲ་ཤིས། well your code now even prints even numbers which should be skipped
☺
+ 1
Remove 3rd, 12th, 13th, 14th, 15th lines and in 2nd line use range (1, n, 2)
+ 1
L18H7N1N8 bro I got my mistake
I just wrote Sololearn instead of SoloLearn
+ 1
Abhishek Singh ok 🐤
0
Well your code fails the first test only bro
0
Well it's 1
But in your code it would be neglected
😇
0
Thx Shivani 📚✍ [Less Active]
For your help
It worked
My code gives same output but fails in secobd test don't know why but Thank you very much
0
Hi! his code is correct. he works. tell you where the error is?
0
Shivani 📚✍ [Less Active] explain why in the condition of the cycle you put after n, -> 2? what does that give?
0
simply put this is the iteration step of the loop?
0
Im found your mistake!
0
yarak
0
Hello
0
Hi,Iran
0
Hii