How to print types within a list

前端 未结 6 1669
自闭症患者
自闭症患者 2021-01-03 02:01

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

6条回答
  •  一生所求
    2021-01-03 02:38

    use the type built in function of python.

    lst = ['string', 1, 2, 'another string']
    for element in lst:
       print type(element)
    

    output:

    
    
    
    
    

提交回复
热议问题