newbie here again. I am trying to accomplish the following question but stuck on the condition in bold:
- get user input in variable:
about_pet
- using a series of if statements respond with appropriate conversation
- check if "dog" is in the string about_pet (sample reply "Ah, a dog")
- check if "cat" is in the string about_pet
- check if 1 or more animal is in string about_pet
- no need for else's
- finish with thanking for the story
Code I wrote:
about_pet = input("Enter a sentence about a pet: ")
if 'dog' in about_pet.lower():
print ("Ah, a dog")
if 'cat' in about_pet.lower():
print ("Ah, a cat")
elif 'dog, cat' in about_pet.lower():
print ("Ah, there is one or more pet")
print("Thank you for your story")
I tried few other ways but stuck. Could you help me to solve this?
Thank you in advance!
Thank you all for help! I dug up the course forum and seems to me the instructor is pitching to use boolean. i.e 'dog' in about_pet.lower() == True to verify if the input statement has more than one pet or not. I am stuck here how to utilize boolean to check the input statement.
Thank you all again for help!
Aucun commentaire:
Enregistrer un commentaire