{"id":42,"date":"2012-11-06T01:55:00","date_gmt":"2012-11-06T09:55:00","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=42"},"modified":"2019-12-06T10:59:31","modified_gmt":"2019-12-06T16:59:31","slug":"multidimensional-array-in-python","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/multidimensional-array-in-python\/","title":{"rendered":"Multidimensional array in python"},"content":{"rendered":"
\n#!\/usr\/bin\/python \nrows=5;cols=2 \nplayers=[[0]*cols for _ in xrange(rows)] \nprint "####### Print Original Array ###################" \nprint players \nprint "\\n" \n\nprint "####### Direct Access ###################" \nprint "going to set [0][0]=S9 and [3][1]=D3" \nplayers[0][0]='S9' \nplayers[3][1]='D3' \nprint players \nprint "\\n" \n\nprint "####### Append Col ###################" \nprint "going to add to [2] value C7, and add to [4] value S4" \nplayers[2].append('C7') \nplayers[4].append('S4') \nprint players \nprint "\\n" \n\nprint "####### Append Row ###################" \nprint "going to add row [5]" \nplayers.extend([[0]*cols]) \nprint players \nprint "\\n" \n\nprint "####### Print Complete Rows ###################" \nfor row in range(len(players)): \n print players[row] \nprint "\\n" \n\nprint "####### Print item for item, by Column by Row ######" \nfor row in range(len(players)): \n for col in range(len(players[row])): \n print str(players[row][col]).rjust(10), \n print\n<\/pre><\/div>\n\n\nREF: http:\/\/stackoverflow.com\/questions\/261006\/multidimensional-array-python<\/p>\n","protected":false},"excerpt":{"rendered":"
REF: http:\/\/stackoverflow.com\/questions\/261006\/multidimensional-array-python<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}