Issue 31063: List Comprehension Bug (original) (raw)

Issue31063

Created on 2017-07-28 05:10 by hyunjaemoon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Screen Shot 2017-07-27 at 9.59.40 PM.png hyunjaemoon,2017-07-28 05:10 Photo
Messages (3)
msg299363 - (view) Author: Hyun Jae Moon (hyunjaemoon) Date: 2017-07-28 05:10
Please check the photo attached. This was tested on Python 3.6.0. It seems that there is a bug in list comprehension. The list b should include 84 as well according to the code I wrote. I believe this is a quite severe bug. Thank you very much.
msg299364 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2017-07-28 05:27
This isn't a bug. 84 appears twice in the list, the first time at index 9. The .index() method finds the first (leftmost; smallest index) occurrence. Since 9 isn't even, the `if` test isn't satisfied, so 84 does not appear in the result.
msg299365 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2017-07-28 05:39
In the future, please do not post screenshots, please copy and paste the text. Screenshots are hard or impossible for the blind or visually impaired to see, but they can use a screen reader to work with text.
History
Date User Action Args
2022-04-11 14:58:49 admin set github: 75246
2017-07-28 05:39:01 steven.daprano set nosy: + steven.dapranomessages: +
2017-07-28 05:27:18 tim.peters set status: open -> closednosy: + tim.petersmessages: + resolution: not a bugstage: resolved
2017-07-28 05:10:01 hyunjaemoon create