python列表操作?该怎么解决

python列表操作??

[temp for temp in msg_temp if index <= total_count]

怎么写让index在每次if成功后加1?
------解决思路----------------------

list(msg_temp)[2:12]

------解决思路----------------------
顶5L,slice即可。