Write a program that takes in input from the user and prints whether or not it c
ID: 3744839 • Letter: W
Question
Write a program that takes in input from the user and prints whether or not it contains the string "dog". Recall that you can use the "input()" command (already present below) to get input from the user. When completed, your program will accept such strings as "dog", "bulldog", and "dogfish" - all of which are good dogs. Your entire program should be one line long. Note: You will need to determine if one string contains another string - there is a special operator for this!
input("What's your favorite animal?")
requires answer without "if"
answer will be one line of code
Explanation / Answer
please do upvote.If you have any problem do comment and i shall be happy to help you.Thanks for using chegg.
---------------------------
#the special operator is "in"
print ("dog" in input("whats's your favorite animal food??? :"))
#explaination
#the input function asks what is your favourite animal food?? and then takes input from user
#then the "in" operator checks if string "dog " is present in input of user
#the result is displayed by print statement
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.