6 ms·
you can prove it by opening a terminal, typing "python", hitting enter, then copying my line and verifying the result. whats your sticking point?
by wayn3 9y ago
you can prove it by opening a terminal, typing "python", hitting enter, then copying my line and verifying the result.
whats your sticking point?
- odonnellryan 9y agosum([j*2 for j in range(0, 11/2)]) ? It's not right. It doesn't give you the value 10, as you'd "expect".
- wayn3 9y ago0 2 2+4 = 6 2+4+6 = 12 if you sum even numbers, starting from 0, "10" is not a possible result. i dont know what youre trying to do there.
- odonnellryan 9y agoI mean the list: [j*2 for j in range(0, 11/2)] Does not give you the item "10" in the list. So it skips 10...
- wayn3 9y agoyea, because 5 is the end of the range. if you do sum(range(0,10,2)), 10 isn't reached either. why are we having this discussion?
- odonnellryan 9y agoYeah, but if you write "end_range" I'd expect that to be the end range. So your implementation should actually be something like: [j2 for j in range(0, (11+1)/2)] Your code is wrong. sum(range(0,11,2)) works as expected, [j*2 for j in range(0, (11)/2)] does not.
- wayn3 9y agocongrats.
- odonnellryan 9y agoWhat? You seem like you have issues.