Reputation: 139
I want to populate the datatype of the list element into the List.
A=['X',123,'Xcw-123','ABC-er']
B=['string','int','string','string']
I tried to create this using type like.
A=[type(i) for i in A]
But I am getting list like:
[<class 'str'>, <class 'int'>, <class 'str'>,<class 'str'>]
Anyone suggest me another approach for this.
Upvotes: 0
Views: 59
Reputation: 3121
AA = [type(i).__name__ for i in A]
print(AA)
Output
['string', 'int', 'string', 'string']
Upvotes: 1