python - printing certain positions from a matrix -


if matrix [[1,2,3,4],[5,3,6,2],[7,7,7,2],[9,7,5,3]]

and want print positions of second row output this:

[1][0] [1][1] [1][2] [1][3] 

i think need use for loop not sure how.

thnx

python provide built-ins every purpose. use enumerate function , string formatting:

for i, j in enumerate(matrix[1]):     print '[1][{}] contains {}'.format(i, j) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -