Nested function: Difference between revisions

added python
m (Remove unnecessary empty lines)
(added python)
Line 26:
}
 
Console.WriteLine(MakeList(". "));</lang>
</lang>
 
=={{header|JavaScript}}==
Line 41 ⟶ 40:
}
 
console.log(makeList(". "));</lang>
</lang>
 
=={{header|Lua}}==
Line 56 ⟶ 54:
end
 
print(makeList(". "))</lang>
 
</lang>
=={{header|Python}}==
{{works with|Python|3+}}
<lang python>def makeList(separator):
counter = 1
 
def makeItem(item):
nonlocal counter
result = str(counter) + separator + item + "\n"
counter += 1
return result
 
return makeItem("first") + makeItem("second") + makeItem("third")
 
print(makeList(". "))</lang>
 
=={{header|zkl}}==
Anonymous user