1. 程式人生 > >Python(67)_寫函式,判斷使用者傳入的物件(str,列表,元組)的每一個元素是否有為空,並返回

Python(67)_寫函式,判斷使用者傳入的物件(str,列表,元組)的每一個元素是否有為空,並返回

#-*-coding:utf-8-*-
'''
寫函式,判斷使用者傳入的物件(str,列表,元組)的每一個元素是否有為空,並返回
'''
def func(x):
    '''str'''
    if type(x) is str and x:
        for i in x:
          if i == ' ':
              return True
    elif x and type(x) is list or type(x) is tuple:
        for i in  x:
            if not i:
                
return True print(func([1,'',9])) print(func([]))