warship warship - 1 year ago 38
Python Question

Type of all elements in Python list

Is there a way to quickly print out the type of all the elements of some given list in Python?

For example

[1, 2, 3.5]
would give
int, int, float

The closest existing resource I've found to answering my question is: Test type of elements python tuple/list, which just gives holistic True/False outputs (which is not what I'm looking for).

Leb Leb

Try the following:

for l in lst:

Where lst = [1,2,3.5]