how to print 2d array in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to print 2d array in python

29th Jun 2016, 6:36 AM
pulkit29
pulkit29 - avatar
4 Answers
0
I suppose there is no such concept of multidimensional array in python, but u can use list within list.
29th Jun 2016, 7:40 AM
Abhishek kumar
Abhishek kumar - avatar
0
yep list within list is same as 2D array such as g=['abc',d ,e,f] so writing g[0][2] gives c
29th Jun 2016, 10:16 AM
Nishant Sardana
Nishant Sardana - avatar
0
in order to print all of the 2D list values use pprint function first import it : from pprint import pprint
29th Jun 2016, 12:33 PM
zarinpy
zarinpy - avatar
0
I use: def prarr(arr): for row in arr: print(row) if you don't like the brackets and commas, use: print(*row)
25th Sep 2016, 2:35 PM
Ralf