A simple list, that I want to loop through to print each element twice. Each time to add a different prefix. The output will be appended into a new list.
List1 = ["9016","6416","9613"]
The ideal result is:
['AB9016', 'CD9016', 'AB6416', 'CD6416', AB9613', 'CD9613']
I have tried below and but the output is:
new_list = []
for x in List1:
for _ in [0,1]:
new_list.append("AB" + x)
new_list.append("CD" + x)
print (new_list)
['AB9016', 'CD9016', 'AB9016', 'CD9016', 'AB6416', 'CD6416', 'AB6416', 'CD6416', 'AB9613', 'CD9613', 'AB9613', 'CD9613']
And I can't use:
new_list.append("AB" + x).append("CD" + x)
What's the proper way to do it? Thank you.