[Tutor] for loop

Tiago Saboga tiagosaboga at gmail.com
Wed Jun 11 04:01:26 CEST 2008


On Tue, Jun 10, 2008 at 09:36:47PM -0400, Sean Novak wrote:
> I know I'm going to feel stupid on this one..
>
> I would normally write this in PHP like this:
>
> for($i=1; i< count($someArray); $i++)
> {
> 	print $someArray[i]
> }
>
> essentially,, I want to loop through an array skipping "someArray[0]"
>
> but in python the for syntax is more like foreach in PHP..
>
> I've tried this to no avail
>
>  count = 0
>  for i in range(1,10):
> 	 if count == 0:
> 		continue
> 	else:
> 		count += 1
> 		print i
> 		continue
>
> it prints absolutely nothing.

The count var is never updated. What about:

for i in someArray[1:]:
    print i


Tiago Saboga.


More information about the Tutor mailing list