0

I have a n-array like this:

[[167. 207. 277. 480.   1.]

 [294. 210. 385. 471.   2.]

 [448. 212. 532. 474.   0.]]

I want to store there row values in 4 variables say a,b,c,d as I want them to write in a file row by row by iterating over the n-array, as I have a lot of these arrays and want them to store in a file.

kalehmann
  • 4,821
  • 6
  • 26
  • 36
sharma_re
  • 87
  • 7
  • 1
    I don't see how assigning rows to variables is related to writing the data to files – roganjosh Oct 10 '18 at 10:17
  • 1
    Your question is a bit ambiguous. Can you provide the expected output what you want to achieve? Also a code snippet of what you have tried so far? – Amit Bhardwaj Oct 10 '18 at 10:17
  • i want to store the first row values in these variables in a,b,c,d and then iterate next row and then again store next values. – sharma_re Oct 10 '18 at 10:24

1 Answers1

1

I think this is what you are looking for:

n_array = [[1,2,3,4],
       [5,6,7,8],
       [9,10,11,12]]

for a, b, c, d in n_array:
    print ("a = ", a)
    print ("b = ", b)
    print ("c = ", c)
    print ("d = ", d)
eiram_mahera
  • 950
  • 9
  • 25