2 Replies - 1259 Views - Last Post: 03 March 2013 - 06:32 AM Rate Topic: -----

#1 pietomb00  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 68
  • Joined: 28-June 11

Getting element from a list

Posted 03 March 2013 - 06:16 AM

Hi All,

I have a list:

[((5,4), 'South' , 1), ((4,5), 'West', 1)]


And I'm trying to get the co-ordinates out of it, but I have no idea how, any advice would be greatly appreciated.

My list is called successors and I've tried:

successors[0] 


but of course that just gets the whole of the first element. The list is defined as (co-ordinate, action, time)

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Getting element from a list

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2151
  • View blog
  • Posts: 3,307
  • Joined: 21-June 11

Re: Getting element from a list

Posted 03 March 2013 - 06:25 AM

Tuples can be indexed the same way that lists can. So you can just use [0] again to get the first element of the tuple, i.e. successors[0][0].

This post has been edited by sepp2k: 03 March 2013 - 06:25 AM

Was This Post Helpful? 1
  • +
  • -

#3 pietomb00  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 68
  • Joined: 28-June 11

Re: Getting element from a list

Posted 03 March 2013 - 06:32 AM

Ah I see, Brilliant! Thank you very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1