Build a Pin Extractor - Step 3

Tell us what’s happening:

I have failed to form the global variable named poem. Please help.

Your code so far


# User Editable Region

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'''
def show_poem():
    global poem
     

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0

Challenge Information:

Build a Pin Extractor - Step 3

create a variable outside the function, don’t create a new function

global_poem

return  poem

Did not pass again, . With ‘‘‘ poem is already global, why does input keep repeating the request? Please help.

Regret I am replying to myself below is what I have. Still issue with “not global poem”def pin_extractor(poem):

secret_code = ''

g_poem ='''Stars and the moon

shine in the sky

white and bright

until the end of the night'''

return 'poem'

Another reply below , another unsuccessful attempt. Please help! Console is clear, but code failed with remark “poem needs to be global”.

def pin_extractor(poem):

    secret_code = ''

    poem = '''Stars and the moon

    shine in the sky

    white and bright

    until the end of the night'''

    msg = 'poem' 

    display ('poem',msg)

The poem variable should be outside the pin_extractor function. What change do you need to do to achieve that?

You haven’t called the function with poem as an argument. The first paragraph of the instructions makes clear which function this is for.

What do these lines do in your code?

 msg = 'poem' 

    display ('poem',msg)

adding msg suggested to globalize poem, but did not work.

Did you try calling the pin_extractor function with poem variable as an argument?

What do these lines of code do? They aren’t described in the instructions.

If you update your code you will need to share it again so we can see what changes you made.

1 Like

def pin_extractor(poem):

secret_code = ''

poem = '''Stars and the moon

shine in the sky

white and bright

until the end of the night'''

return poem

This is updated. Still does not pass.

please individuate what is inside the function and what is outside the function, create the poem variable outside the function

Ask questions if there is anything you don’t understand well.

Don’t just try random things.

You need to define a string, and a function. Then pass the variable to the function as an argument.

variable = "this string"

def function(parameter):
   code
   code

function(variable)


I appreciate your response. Does using double ‘‘‘ globalize the poem ? or do I have to perform a different operation. That is what I am asked to do: To globalize.

it’s global because it’s in the global scope, outside the function, like variable in the code snippet posted da pkdvalis

You are not asked to “globalize”

create a poem variable, outside the function

I am convinced it’s global . Does not pass with

debug_pin_extractor(poem)

intended to be a function call.

Thanks for all your help.

Why did you add “debug_” to the name of the function?

Please review how to call a function:

https://www.freecodecamp.org/news/how-to-define-and-call-functions-in-python/

If you are ever not sure how to do something, just search for it. For example, “Python how to call a function” https://duckduckgo.com/?q=python+how+to+call+a+function

def pin_extractor(poem):

secret_code = ''

poem = ‘’'Stars and the moon

shine in the sky

white and bright

until the end of the night’‘’

def pin_extractor(poem):

return poem

Above is my current situation. Did not pass. Current issue is about calling a function.

Please help.

To call a function, just write it’s name and put any arguments in the brackets.

Can you please identify which line of your code calls the function?

“Outside the function” did it. Big burden off! many thanks!!