Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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"")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote