I'm trying to count how many certain string (in this case 'v') exist in a list. But when I run the code, it gives me index out of range error. The list is created by line.split() method
So this is what I've got:
for line in open('cube.obj','r').readlines():
rawdata = line.split()[0:]
data = line.split()[1:]
obj.add_last(data)
if rawdata[0] == 'v':
v_count += 1
cube.obj file is following:
# cube
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 0.0 0.0 1.0
v 0.0 1.0 1.0
v 0.0 1.0 0.0
v 1.0 1.0 0.0
v 1.0 1.0 1.0
f 1 2 3 4
f 6 7 8 5
f 2 3 8 7
f 1 4 5 6
f 3 4 5 8
f 1 2 7 6
Any help is appreciated Thanks!