How can I obtain the expected result below?
data = ['abc', 'def', 'ghi']
Expected result is:
[abc, def, ghi]
My attempt is:
ans = [', '.join([''.join(i) for i in data])]
print ans
['abc, def, ghi']
Try below code:
>>> ans = '[' + ', '.join([''.join(i) for i in data]) + ']'
>>> ans
'[abc, def, ghi]'
>>>
"[" + ", ".join(data) + "]"?"[abc, def, ghi]"? You understand what the quote marks and brackets actually mean, yes?