Concatenate list of string in Python -


hello enthusiast programmers, seems bad @ manipulating lists in python (i come idl world, , struggle python). have list of string, say:

mylist =['boring', 'enjoyable', 'great'] 

and string, say:

s = 'python ' 

and want build list: ['python boring', 'python enjoyable', 'python great']

mynewlist = s + l 

as have done in idl, doesn't work of course ... not able simply! (i.e. without loop , intermediate variables)

thanks help!

s.

use map or list comprehensions:

map(lambda x: "python " + x, mylist)  ["python " + x x in mylist] 

both solutions implicit loop, idl would; inevitable have 1 in scenario. no overt loop for ...:.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -