Answer:
def all_cats(data):
dataArray = data.split(',')
if(data==""):
return True
for i in dataArray:
if('cat' not in i):
return False
return True
print(all_cats("gerbil,catfish,dog,cat"))
print(all_cats("cat,catfish"))
print(all_cats(""))
Step-by-step explanation:
Step 1: define de function and the parameters
def all_cats(data):
Step 2: split the data by ,
dataArray = data.split(',')
Step 3 : validate if is an empty data and return true
if(data==""):
return True
Step 4: Loop over de array data and validate if have cat in each data if not, then return false
for i in dataArray:
if('cat' not in i):
return False
Step 5 if have cat in each one return true
return True
Step 6 Validate with examples
print(all_cats("gerbil,catfish,dog,cat"))
print(all_cats("cat,catfish"))
print(all_cats(""))