Q:

Appending string print output

I want to find word in sentence to give a category to sentence.  For that I have created a function listed below: 
def theme(x):
    category = ()
    for i in x:
        if 'AC' in i:
            category = 'AC problem'
        elif 'insects' in i:
            category = 'Cleanliness'
        elif 'clean' in i:
            category = 'Cleanliness'
        elif 'food' in i:
            category = 'Food Problem'
        elif 'delay' in i:
            category = 'Train Delayed'
        else:
            category = 'None'
        print(category)

the output is :
None
None
AC problem
None
AC problem

How should I save this output to a variable

A:

def theme(x):

    category = []

    for i in x:
        if 'AC' in i:
            category.append('AC problem')
        elif 'insects' in i:
            category.append('Cleanliness')
        elif 'clean' in i:
            category.append('Cleanliness')
        elif 'food' in i:
            category.append('Food Problem')
        elif 'delay' in i:
            category.append('Train Delayed')
        else:
            category.append('None')

    return category

categories = theme(['bla bla AC bla','bla insects bla'])
print(categories)

