-4

I want to filter the x result to know which category would be appended to

def bot():
    kids = []
    adults = [] 
    index = 0
    x = input("enter movie name ")
    for side in x:
        if x == "gun" or x == "kill":
            kids.append(x)
        else:
            adults.append(x)
        print(kids)
        print(adults)

what if x == "top gun" it will ignore it

I need to make it if x has "kill or gun, etc" don't add it to category less than 16 years old recommends

1 Answers1

1

I think you want to compare the individual words. What you are currently doing is iterating over the individual characters. To do this comparison word-wise, I recommend using the split function and iterate over the output of that:

movie_name = input('enter movie name: ')
for word in movie_name.split():
    if word in ('gun', 'kill'):
        kids.append(word)
    else:
        adults.append(word)
Sumner Evans
  • 8,951
  • 5
  • 30
  • 47