Nov-23-2023, 02:53 PM
(Nov-23-2023, 08:40 AM)menator01 Wrote: Example:
def contains_letter(string, letter): for letters in string: if letters == letter: return True return False print(contains_letter('hello', 'h'))
You can simply that to:
def contains_letter(string, letter): return bool(letter in string)
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein