fork download
  1. groups = [['|FOOD|','shrimps','chicken wok','bowl of rice'],['|DRINK|','water','cranberry juice','tea']]
  2. groups = [[''.join([r"""[lemma="{}"]""".format(w) for w in word.split()]) if not word.startswith("|") and not word.endswith("|") else word for word in group] for group in groups]
  3. print(groups)
Success #stdin #stdout 0.02s 9180KB
stdin
Standard input is empty
stdout
[['|FOOD|', '[lemma="shrimps"]', '[lemma="chicken"][lemma="wok"]', '[lemma="bowl"][lemma="of"][lemma="rice"]'], ['|DRINK|', '[lemma="water"]', '[lemma="cranberry"][lemma="juice"]', '[lemma="tea"]']]