Again, this code is so close to being 100% correct! All we need to add to these four variables are the required parameters for the TextSample class to be initialized. We can find what variables are required by looking at the __init__ function of the TextSample class. For example, our __init__ function is defined as the following:
def __init__(self, text, author):
By observing this function signature (that's what these kinds of statements are called), we know that we need to give the TextSample class a text and an author for it to be initialized properly (note: ignore the self parameter).
Now that we know what parameters need to be passed, all we have to do is include those when we make our call. So, for the murder_sample variable, we can do the following:
Note that the murder_note variable was defined earlier in our program (in fact, it was the very first line!). When this line executes, the variable murder_note and string 'Murderer will be passed to the __init__ function of our TextSample class like so:
Then these would be passed down like any other function call we make. Note that the 'Murderer' string is simply the name of the person who authored that text. So, If we were to define the lily_sample variable, instead of 'Murderer' we might give it the name 'Lily Trebuchet' since that is her full name. Here is the full example for Lily:
Again, lily_trebuchet_intro was defined earlier in our program.
For practice, try to go back and add in these parameters for the myrtle_sample and gregg_sample variables. If you have any questions, please let me know!
Again, this code is so close to being 100% correct! All we need to add to these four variables are the required parameters for the
TextSample
class to be initialized. We can find what variables are required by looking at the__init__
function of theTextSample
class. For example, our__init__
function is defined as the following:def __init__(self, text, author):
By observing this function signature (that's what these kinds of statements are called), we know that we need to give the
TextSample
class atext
and anauthor
for it to be initialized properly (note: ignore theself
parameter).Now that we know what parameters need to be passed, all we have to do is include those when we make our call. So, for the
murder_sample
variable, we can do the following:murder_sample = TextSample(muder_note, 'Murderer')
Note that the
murder_note
variable was defined earlier in our program (in fact, it was the very first line!). When this line executes, the variablemurder_note
and string'Murderer
will be passed to the__init__
function of ourTextSample
class like so:__init__(self, murder_note, 'Murderer')
again, ignore selfThen these would be passed down like any other function call we make. Note that the 'Murderer' string is simply the name of the person who authored that text. So, If we were to define the
lily_sample
variable, instead of 'Murderer' we might give it the name 'Lily Trebuchet' since that is her full name. Here is the full example for Lily:lily_sample = TextSample(lily_trebuchet_intro, 'Lily Trebuchet')
Again,
lily_trebuchet_intro
was defined earlier in our program.For practice, try to go back and add in these parameters for the
myrtle_sample
andgregg_sample
variables. If you have any questions, please let me know!