如何检查列表是否包含多种类型,即包含数字和整数的“字符串”

时间:2018-09-28 16:08:25

标签: python python-3.x

def AmIDigits(aList):
#iterate through a list
    for item in aList:      
#check if any values in aList are intergers or string with digit
#check to see if any element is a string with letters
        if type(item) == int or item.isdigit():
    #return concatenation of every element
                return ''.join(str(item) for item in aList) 
        if item.isalpha() in aList:
    #return "The length of the input is len(aList)."
                return "The length of the input is " + str(len(aList)) + "."

仅当aList [0]中有诸如“ hello”之类的内容时,此方法才有效,但如果在其他任何索引中具有数字,则将其添加

0 个答案:

没有答案