I have two questions about the Python list.
- Is there a way to insert items in the beginning and end of the python list? For instance, suppose that I have the list below
A = ["I","am","happy"]
What is the easiest way to generate the list B
below from the list A
, by specifying that I want the additional items to be at the beginning and at the end of the original list?
B = ["<bos>", "I", "am", "happy", "<eos>"]
- suppose now that I want to add a special token
<spec_token>
right before the tokenam
. Is there a way to do so by specifying before which token (am
in this case) I want to insert the<spec_token>
at? So continuing from the previous example, I want to generate the listC
below:
C = ["<bos>", "I", "<spec_token>", "am", "happy", "<eos>"]
Thank you,
PS: Please note that I do not want to use the token index as my parameter to insert a different token into the list. I want to use the specific tokens themselves as my parameter to update the list.