I am trying to create a new list based on the old one, from ['a','b','c'] to ['a12', 'b12', 'c12'].
a classic way can be:
a = ['a','b','c']
aa = []
for item in a:
aa.append(item + '12')
print aa
however I want to learn a better way so I tried:
aa = a.extend('12%s' % item for item in l[:])
and
aa = [item.join('12') for item in l]
but they don't produce the most correct one. what are the better ways?
thanks.
aa = [item + '12' for item in a]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With