Python Concat String from A List Aug 23rd 2021 Words: 80

Assume a list of keyword is given, eg. ['abc', 'def', 'ghjk', 'lmn'], and an output string is generated from the list using a specific template. For example, string '(abc)(def)(ghjk)(lmn)' is the desired output.

Here is a neat Python code to achieve it:

''.join(f"({word})" for word in ['abc', 'def', 'ghjk', 'lmn'])