What does i[b] % [/b]2 == 0 mean, when i is an integer from a range? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What does i[b] % [/b]2 == 0 mean, when i is an integer from a range?

I saw this expression as a part of challenge: https://code.sololearn.com/cbuD0LFnE6LQ/#py Moreover, I always get a syntax error

18th Aug 2018, 5:39 PM
P.W.R.
P.W.R. - avatar
2 Answers
+ 1
Lst = [] for i in range(12): if i % 2 == 0: Lst.append(i) continue print(Lst) this prints all even numbers... not sure about the 'b' variable. So this takes each number, from 1-11 and divides them by 2. If their remainder is 0, that number is added to the 'Lst' list. Then 'Lst' is printed to the screen.
18th Aug 2018, 6:02 PM
Steven M
Steven M - avatar
+ 1
Thank you Steven, I was specially interested in the terms [b] and [/b]. In the meantime I think, that this was just some kind of formatting error in the presentation of the challenge task. But it looked "pythonic" ;-)
18th Aug 2018, 8:37 PM
P.W.R.
P.W.R. - avatar