Write a program that takes in input from the user and prints whether or not it c
ID: 3744827 • 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?")
Explanation / Answer
animal = input("What's your favorite animal?") print(animal + " contains string "dog"" if "dog" in animal else animal + " does not contains string "dog"")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.