Re: Python (Trouble with Aliens!)

  • From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 17 Apr 2009 05:27:47 -0600

dam them troublesome alians, eh? ;)

What your doing is a for each loop:
for i in alians.
Basically it's going to go through the list of alians, and i gets assigned to 
the new alian, so you would use something like:
i.move()
rather than alians[i].move
etc
HTH,


Thanks,
Tyler Littlefield
Web: tysdomain.com
email: tyler@xxxxxxxxxxxxx
My programs don't have bugs, they're called randomly added features.

  ----- Original Message ----- 
  From: BlueScale 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Friday, April 17, 2009 5:17 AM
  Subject: Python (Trouble with Aliens!)


  Hi,
  I am having some trouble with my aliens.  Here's the code:
  for i in aliens:
    aliens[i].move()
    if aliens[i].getxpos() == x:
     lockOn.play()
  The error I am getting is:
  TypeError: object cannot be interpreted as an index
  Can someone please help me make my aliens behave better?
  Thanks 

Other related posts: