[Tutor] for loop

bob gailer bgailer at gmail.com
Wed Jun 11 04:43:02 CEST 2008


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..

for item in somearray[1:]:
  print i
>
> 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.
>

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



More information about the Tutor mailing list