tsrha
December 27, 2025, 5:06am
1
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
ILM
December 27, 2025, 7:19am
2
create a variable outside the function, don’t create a new function
Tsirha
December 27, 2025, 7:57am
3
global_poem
return poem
Did not pass again, . With ‘‘‘ poem is already global, why does input keep repeating the request? Please help.
tsrha
December 27, 2025, 11:43am
4
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'
tsrha
December 27, 2025, 12:11pm
5
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)
tsrha
December 27, 2025, 12:48pm
7
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
tsrha
December 27, 2025, 6:42pm
9
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.
ILM
December 27, 2025, 6:47pm
10
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)
tsrha
December 27, 2025, 8:33pm
12
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.
ILM
December 27, 2025, 8:43pm
13
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
tsrha
December 27, 2025, 9:15pm
15
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
tsrha
December 28, 2025, 1:05am
17
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?
tsrha
December 28, 2025, 2:22am
19
“Outside the function” did it. Big burden off! many thanks!!