Search⌘ K
AI Features

Puzzle 15: Explanation

Explore how Python manages Boolean values and logical operations before True and False were introduced. Learn to use str.find and the in operator for substring detection, and understand how to define Boolean logic for custom objects using the bool method.

We'll cover the following...

Try it yourself

Try executing the code below to verify the result:

Python 3.8
name = 'Waldo'
text = 'Can you find where Wally is?'
if text.find(name):
print('Found Waldo')
else:
print('Cannot find Waldo')

Explanation

Note: The str.find documenta ...