you could put an if statement within an if statement so it checks if the sentence contains the word cat
first then if it does it goes on check if it also contains the word dog
to see if both words are in the string.
about_pet = raw_input("A sentence about your pet")
if "cat" in about_pet:
if "dog"in about_pet:
print "wow, you have one more pets! Thanking you reading my story:) "
elif "dog" in about_pet:
print "Ah, a dog. Thanking you reading my story:) "
elif "cat" in about_pet:
print "Oh, a cat. Thanking you reading my story:) "
I know this might not be the cleverest solution but it is quite easy to understand.
To simplify it you can check them one after another using an and
if "cat" in about_pet and "dog" in about_pet:
or:
if "cat" and "dog" in about_pet:
If you are using Python 2.7.10 ,you also need to use raw_input
instead of input
as in Python 2.7.10 input
only accepts integers and float. And if you're using python 2.7.10(as i am) i don't do my print in brackets as it prints out the brackets sometimes. Also i have a suggestion to add code for when the user says they don't have a pet using an else
at the end. Plus you don't have to put sentences in separate speech marks. I hope this helped!