L = ['abc', 'ADB', 'aBe']
L[len(L):]=['a1', 'a2'] # append items at the end...
L[-1:]=['a3', 'a4'] # append more items at the end...
… works, but ‘a2’ is missing in the output:
['abc', 'ADB', 'aBe', 'append', 'a1', 'a3', 'a4']
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think that the -1 is pointing at the last element of the list, which gets overwritten by ‘a3’. As described here, you can do a