简体   繁体   中英

Python matrix in matrix in matrix

In my program I use this var:

payoff_matrix = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]

And i need to check (4,4) and (2,2), (It can be anything) I use

  a=payoff_matrix[0]
  b=a[0]
  c=b[0]
  d=b[1]

And result is

  c=4
  d=4

Can I go to that like

c=payoff_matrix[0].[0].[0]

or somehow?

In [4]: mat = [ [(4,4),(1,6)] , [(6,1),(2,2)] ]

In [6]: c,d=mat[0][0]    #here mat[0] is [(4,4),(1,6)], invoking [0] on this yields [4,4]

In [7]: c
Out[7]: 4

In [8]: d
Out[8]: 4


In [9]: a,b=mat[1][1]  #here mat[1] is [(6,1),(2,2)], invoking [1] on this yields [2,2]

In [10]: a
Out[10]: 2

In [11]: b
Out[11]: 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM