I have code that generates a list (target = [ ]) by appending strings (token) to it.
Now I have another list say A = [['A', 'B'], ['C', 'D']] that I would like to add to the target list, without touching the original list. Just add on to the original, may I know how to do it? thanks
def read_samples_by_string(self, path):
for tokens in self.read_tokens(path):
target = []
print(type(target)) # this is <type 'list'>
for token in tokens:
target.append(token)
print(type(token)) # this is <type 'str'>
yield target
print(target)
Input list :
A = [['A', 'B'], ['C', 'D']]
output :
['O','X', 'Y', 'Z']
['L', 'M']
['J', 'K', 'W']
Expected output
['O','X', 'Y', 'Z']
['L', 'M']
['J', 'K', 'W']
['A', 'B']
['C', 'D']