Troubles splicing lists

I am trying to skip the first element of the list build_pass_list[j] when using a for loop. I have been unable to figure out how to splice of the [1:]. I am assuming for now that because it is a sublist it does not have the same properties as the list itself. Python 2.2.2

I am trying to skip the first element of the list build_pass_list[j] when using a for loop. I have been unable to figure out how to splice of the [1:]. I am assuming for now that because it is a sublist it does not have the same properties as the list itself. Python 2.2.2

Any particular reason you aren't using Python 2.3?

Splicing the back end of the lists works.

Code:

build_pass_list[j][:1]

Splicing the front end does not work.

Code:

build_pass_list[j][1:])

Could it be because of the stray ')' you have in there? Because slicing is the same from either end. Without specifics on what errors you are getting or what incorrect behavior you are seeing, I'm not sure what's going wrong for you.

When you say it doesn't work, what does that mean? Does it throw an exception, and if so then what is it? Or does it not print the results you expect? If so then what do you expect, and what does it actually print?

What is in build_pass_list? If it contains any non-indexible objects then it will throw an exception.

In the outer loop why do you use range to get an index into the list, instead of stepping through the list elements directly?

e.g. instead of

Code:

for j in range(len(build_pass_list)):
for k in range(len(build_pass_list[j][1:])):
print k

do

Code:

for j in build_pass_list:
for k in range(len(j[1:])):
print k

In the inner loop, what do you expect range(len(j[1:])) to produce? It creates a list of the numbers 0 to N-1, where N is the length of the list j. Are you expecting it to produce the numbers 1 to N?

Strike: I'm using 2.2 because I don't have a choice in the matter. Secondly it was not throwing an error it was just not starting the loop from the second element. From playing around on the python command line the syntax I was using appeared to be correct.