Error: object is not subscriptable

Rhinoscript: Why am I getting an ‘object is not subscriptable’ error when going through the groups via the index. Can we not iterate through the list of groups? Create a couple groups in your active document and run the following code:

    grps = Rhino.RhinoDoc.ActiveDoc.Groups
    
    print 'Number of groups: ' + str(len(grps))
    print 
    
    y = 0
    for x in grps:
        print 'Group ' + str(y) + ' Name: ' + x.Name
        y += 1
    
    print
    
    for y, x in enumerate(grps):
        print 'Group ' + str(y) + ' Name: ' + x.Name

    print
    
    for x in range (len(grps)):
        print 'Group ' + str(x) + ' Name: ' + grps[x].Name

Hi @Mike24, you might make a list for it (the grouptable is not a list):

grps = [g for g in Rhino.RhinoDoc.ActiveDoc.Groups]

_
c.

@clement - Thanks.