If we have a string and numeric value too in an array then , if we print that array then output array will be string or of mixed

Related to python

4/6/2019 2:40:05 AM

Yash Srivastava

5 Answers

New Answer


The type (str, int, etc.) of an element in a list won't change if we print the list. lst = ["hello", "world", 42] print(lst) print(type(lst)) print([type(i) for i in lst]) Output: ['hello', 'world', 42] <class 'list'> [<class 'str'>, <class 'str'>, <class 'int'>]


The numpy array will not be of number or mixed type it will be of string type A=np.array(["yash","harsh",1]) print(A) So output will be ["yash","harsh","1"] string type


An Array can store elements of one type only!!




Nice question