Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Python help pls!!?
I need a function that "Given arbitrary values s and t, return True if both values are strings and s is a substring of t."
1 Answer
- ChrisLv 75 years ago
Audrey, pls.
s in t, not "s" in "t".
You need to check the strings that were passed to the function, not the literal characters "s" and "t".
Also, like last time, you don't need "return True" and "return False", since the expression will evaluate to either True or False and you can thus return the expression itself.
def is_substring(s, t):
... return type(s) is str and type(t) is str and s in t
Also, people usually acknowledge in some form that their question was answered before posting a new one.