I'm looping over all lines in a file, splitting each line into tokens based on whitespace. For example, a line: circle 1 2 3
would be split into 4 tokens, circle
, 1
, 2
, 3
.
If the line begins with a comment (#
) or is empty, my tokenList
is also empty. If this is the case, I can't check tokenList[0]
etc.
If the size of the list is 0, I want to jump to the next line - the next loop in the for
loop:
for line in self.myFile:
tokenList = self.getTokens(line)
if len(tokenList) == 0:
## ISSUE HERE
if tokenList[0] == "shape":
s = RayTracerShapes.Shape()
self.scene.addShape(s)
I tried break
, but this seems to jump right out of the loop, rather than ending the current iteration. Is there a way to jump out of the loop I'm in, and into the next loop, without jumping right out of the for loop altogether?