0
Can some explain this code in python. I think I'm misunderstanding the use of the modulous symbol.
nums = [55, 44, 33, 22, 11] if any([i % 2 == 0 for i in nums]): print("At least one is even")
4 Réponses
0
Modulus functions work is to output the remainder.
Eg| - 5%2 =would give 1 because 2*2 =4 and the remainder remains 1.
Now I think you might be able to understand the code better.
Try and if you still don't understand then comment.
0
Is i representing each number in the list?
0
Paul Rethier Yes, i represents each number in turn
Maybe you should familiarise yourself with 'list comprehensions' as that appears to be where your issue is.
0
That's the section I'm working on. I just wasn't understanding what I represented in that code and kept getting the answer wrong. I appreciate the help.