20 AnswersNew Answer
20 AnswersNew Answer
your code is also working. just instead of the right phrase SoloLearn, you wrote Sololearn. this is also important
Thank you so much Ярослав Вернигора(Yaroslav Vernigora) I am so stupid lol 😆🙃😂
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)
Ярослав Вернигора(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
བསོད་ནམ་བཀྲ་ཤིས། well your code now even prints even numbers which should be skipped ☺
Remove 3rd, 12th, 13th, 14th, 15th lines and in 2nd line use range (1, n, 2)
L18H7N1N8 bro I got my mistake I just wrote Sololearn instead of SoloLearn
Abhishek Singh ok 🐤
Here is the correct code : n = int(input()) for x in range(1, n): if x % 2 == 0: continue 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)
Well your code fails the first test only bro
Well it's 1 But in your code it would be neglected 😇
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
Hi! his code is correct. he works. tell you where the error is?
Shivani 📚✍ [Less Active] explain why in the condition of the cycle you put after n, -> 2? what does that give?
simply put this is the iteration step of the loop?
Im found your mistake!
SoloLearn Inc.4 Embarcadero Center, Suite 1455
Send us a message