I have a list of strings. I need to add a string to all of them, and then a second string to only two of them. I am trying the following:
[s + ' help ' for s in [ ['me '].extend(['with ' + t for t in ['things', 'please']]) ] ]
What I would expect is the following:
['me help ', 'with things help ', 'with please help ']
Nothing happens when I try to run this in iPython. It seems to have a problem with using the extend method on a 'newly created' list. I am unsure, and relatively new to python.
EDIT:
To be more explicit, in the above example, the original list would be:
['me', 'things', 'please']
I need to add 'help ' to all of them, and 'with ' to only the latter two.
And I get an error when running the above line of code:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Second Edit:
I am more focused on the location of the elements. I want a string added to every element of the list, excluding the first, and then a second string added to the entire new list. My above approach was a first stab at what it should be (in the most 'pythonic' way), but it does not work. I understand why it does not work, but I am unsure how to rewrite the above line into something that will work.