Tell us what’s happening:
I don’t think ive understood this workshop well, the terminal tells me that there is a syntax error : apparently the concatenation (+=) doesnt work ? I saw an indent error too, i also think that my if statement isn’t well written overall.. Can someone explain this to me, please ?
Your code so far
def pin_extractor(poem):
secret_code = ''
lines = poem.split('\n')
for line_index, line in enumerate(lines):
words = line.split()
# User Editable Region
if len(words) > line_index in secret_code += str(len(words[line_index])):
pass
# User Editable Region
return secret_code
poem = """Stars and the moon
shine in the sky
white and bright
until the end of the night"""
print(pin_extractor(poem))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Challenge Information:
Build a Pin Extractor - Step 14
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-pin-extractor/6855918e87c33c6979d21d3f.md at main · freeCodeCamp/freeCodeCamp · GitHub
Hey @Cladvyr
I’ll try my level best to explain this workshop.
So the main objective of this workshop is to extract a numeric pin from a poem reading diagonally. It takes the first word of the first line, second word of the second line, the third word of the third line and so on, then records the length of each.
One example would be:
The sun rises
Over the green hills
And birds sing loudly
So,
Line 0: first word = The → Length = 3
Line 1: second word = the (again) → length = 3
Line 3: third word = sing → length = 4

You can see in the above image how a diagonal is forming.
So our final pin would be 334
This is the objective of the workshop. Now coming to the step instructions,
Look at this example:
The sun rises
Over the green hills
And birds
So according to goal, third line should have the third word (refer the first above example, we are going diagonally over here), but its not there so we should put a check to confirm whether our line is having enough words to form the diagonal.
So step instructs us to check for the condition first (There are enough words to form the diagonal) and then inside the if block, add following line
secret_code += str(len(words[line_index]))
That’s it! Hope it helps.