Python:如何在列表中打印类型

问题描述:

因此给了我一个列表,我必须打印列表中每个项目的类型.我可以清楚地看到有字符串和整数,但是我需要它才能在Python中打印出来.我们刚刚学习了 for循环,所以我觉得这就是他们想要的,但我无法打印出来.

So I was given a list and I must print the type of each item in the list. I can clearly see that there are strings and integers but I need it to print out in Python. We just learned for loops so I feel like that is what they are looking for but I cannot get it to print out.

ls = [type(item) for item in list_of_items]
print(ls)