[Tutor] skip/slice more than every second?

Alan Gauld alan.gauld at btinternet.com
Tue Sep 29 11:36:13 CEST 2015


On 29/09/15 08:33, Peter Otten wrote:

>> hide 1 show 2,3,4 hide 5, show 6,7,8 etc.
>>
>> thanks in advance
>
> You can use del on a slice:

And just for kicks you can use a list comprehension:

print [n for i,n in enumerate(a) if i%4]

hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list