It is essentially a shorter and probably more performant version of this:

i = 0
for item in aList:
    print "{0}{1}".format(item, i)
    i += 1



On Aug 1, 2013, at 12:32 AM, Justin Israel wrote:

> Do you mean just using a counter? You can do it a couple ways. If I am 
> looping over a list, then I tend to use enumerate:
> 
> aList = someListofStuff()
> 
> for i, item in enumerate(aList):
>       print "{0}{1}".format(item, i)
> 
> Is that what you are after?
> 
> 
> On Aug 1, 2013, at 12:27 AM, Daz wrote:
> 
>> Heya
>> 
>> Uhh this is not really maya related but maybe some1 can help me with it.
>> 
>> Basically I have a list of objects and I want to add a number to each object 
>> each time loop goes over it so. Basically in maya terms if I remember it 
>> correctly :
>> 
>> obj = cmds.select("*cat*")
>> 
>> for list in obj:
>>   print "test" + str(1)
>> 
>> so if I have 4 objects I want to have names 
>> test1
>> test2
>> test3
>> test4
>> 
>> How can I do it? I know I'm missing something basic uhh. 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>> 
>> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to