Puzzle 19: Holding Out for a Hero
Let's solve a pandas series puzzle using the any and find methods.
We'll cover the following
Guess the output
Try to guess the output of the code below:
import pandas as pdheros = pd.Series(['Batman', 'Wonder Woman', 'Superman'])if heros.str.find('Iron Man').any():print('Wrong universe')else:print('DC')
Quiz
Q
What is the output of the code above?
A)
DC
B)
Wrong universe
C)
SyntaxError
D)
TypeError
Get hands-on with 1300+ tech skills courses.