Can't you do `range(1, len(gallery_items))` in the if block and thus remove this statement?