Imagine I have a list like this:
a = [1,2,3,4,5,6]
Using a lambda function, I would like to return two elements at a time, so the result would be:
res = [[1,2], [2,3], [3,4], [4,5], [5,6]]
Any suggestions?
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 avoids creating a copy of your original list, which may be relevant if it’s very big.