You have
x = ['a', 'b', 'c']
y = [1, 2, 3]
And want to insert list y at the beginning of x:
x = [1, 2, 3, 'a', 'b', 'c']
What is the optimal solution to do this in Python?
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.
This simple solution runs twice as fast as the solution with
dequefor smaller input sizes:However, it becomes slower for larger sizes of input: