Python Forum
hide object type in printing - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: hide object type in printing (/thread-21133.html)



hide object type in printing - shirin - Sep-16-2019

Hi
I have an 2d array A.which each elements of it is a list . when I print A, It gives me sth like this:

[list([]) list([]) list([])]
[list([]) list([]) list([])]
[list([]) list([]) list([])]]

but i dont like to show 'list' word in the print result! Sad
thanks for ur help in advance.
+i use python 3


RE: hide object type in printing - buran - Sep-16-2019

Please, post whatever code you have - in python tags


RE: hide object type in printing - shirin - Sep-17-2019

this is what I wrote:

import numpy as np
A=np.zeros((3,3),dtype=object) #or object

for i in range(3):
    for j in range(3):
        A[i,j]=[] #wanna be empty list to be filled later 

print(A)
output:
Output:
[list([]) list([]) list([])] [list([]) list([]) list([])] [list([]) list([]) list([])]]