Why the second test is failing ['SOLVED'] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why the second test is failing ['SOLVED']

https://code.sololearn.com/cj2Zm5YLiJ4I/?ref=app

26th Feb 2021, 5:29 PM
Abhishek Singh
Abhishek Singh - avatar
19 Answers
+ 5
your code is also working. just instead of the right phrase SoloLearn, you wrote Sololearn. this is also important
27th Feb 2021, 6:50 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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)
26th Feb 2021, 6:14 PM
Shivani 📚✍
Shivani 📚✍ - avatar
+ 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
26th Feb 2021, 6:48 PM
Shivani 📚✍
Shivani 📚✍ - avatar
+ 3
Thank you so much Ярослав Вернигора(Yaroslav Vernigora) I am so stupid lol 😆🙃😂
27th Feb 2021, 7:17 AM
Abhishek Singh
Abhishek Singh - avatar
+ 1
བསོད་ནམ་བཀྲ་ཤིས། well your code now even prints even numbers which should be skipped ☺
26th Feb 2021, 7:11 PM
Abhishek Singh
Abhishek Singh - avatar
+ 1
Remove 3rd, 12th, 13th, 14th, 15th lines and in 2nd line use range (1, n, 2)
27th Feb 2021, 2:08 PM
Khushal Neekhra
Khushal Neekhra - avatar
+ 1
L18H7N1N8 bro I got my mistake I just wrote Sololearn instead of SoloLearn
27th Feb 2021, 2:13 PM
Abhishek Singh
Abhishek Singh - avatar
+ 1
27th Feb 2021, 2:15 PM
Khushal Neekhra
Khushal Neekhra - avatar
0
Well your code fails the first test only bro
26th Feb 2021, 5:48 PM
Abhishek Singh
Abhishek Singh - avatar
0
Well it's 1 But in your code it would be neglected 😇
26th Feb 2021, 5:52 PM
Abhishek Singh
Abhishek Singh - avatar
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
26th Feb 2021, 6:23 PM
Abhishek Singh
Abhishek Singh - avatar
0
Hi! his code is correct. he works. tell you where the error is?
26th Feb 2021, 6:24 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Shivani 📚✍ [Less Active] explain why in the condition of the cycle you put after n, -> 2? what does that give?
26th Feb 2021, 6:31 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
simply put this is the iteration step of the loop?
26th Feb 2021, 6:52 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Im found your mistake!
26th Feb 2021, 8:01 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
yarak
28th Feb 2021, 7:35 AM
Maaaaa
0
Hello
28th Feb 2021, 11:22 AM
Deepak Singh
Deepak Singh - avatar
0
Hi,Iran
28th Feb 2021, 2:46 PM
‎Mtaha
0
Hii
28th Feb 2021, 3:04 PM
Raju Chiluvuri
Raju Chiluvuri - avatar