I am stuck on Step 3 from the Build a Pin Extractor activity. Please, could you help me?
Your code so far
def pin_extractor(poem):
secret_code = ''
pin_extractor (poem)
'''Stars and the moon
shine in the sky
white and bright
until the end of the night'''
# User Editable Region
global poem
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
You are very close, but closely examine the steps again. You don’t need a globally referenced poem variable and you need to make sure to call the pin_extractor function with that variable. The poem variable you create should be outside that function.
Let’s use another example that relates to this particular objective!
If I have a function called printWhatISay and I have a parameter called mySaying that just prints out mySaying like this:
def printWhatISay(mySaying):
print(mySaying)
And then I make a second variable that is called mySaying that is outside of the function like so:
def printWhatISay(mySaying):
print(mySaying)
mySaying = '''I like to eat
eat eat
apples and banaynays'''
And then I want to call printWhatISay with that variable, I would do the following:
def printWhatISay(mySaying):
print(mySaying)
mySaying = '''I like to eat
eat eat
apples and banaynays'''
printWhatISay(mySaying)
And this way it uses the outside variable of mySaying as the value for the function and then the function itself uses its own separate mySaying inside of the function.