"David Merrick" <[email protected]> wrote

I have created a Critter object and a Farm object which is two critters. I want to use Critters methods in the Farm object as it just 2 critters in a
list

crit1 = Critter("Sweetie")
crit2 = Critter("Dave")
farmlet = [crit1,crit2]


This creates two critters but it does not create a Farm object,
it only creates a list of two critters. (That might be all you need!
Maybe you don't need a Farm class)

So to call the talk() method of crit1 via the farmlet list:

farmlet[0].talk()

Or for all the critters in the farmlet:

for critter in farmlet:
    critter.talk()

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to