英文:
Split a list into list of tuple with overlapping elements
问题
我想要将列表分割成元组列表,其中第二个元素变成元组的第一个元素
例如:期望输出:
temps = [(-39.5, -27.5), (-27.5,-15.5), (-15.5,-3.5), (-3.5,8.5), (8.5,20.5), (20.5,32.5), (32.5,44.5), (44.5,56.5), (56.5,68.5), (68.5,80.5), (80.5,92.5), (92.5,104.5)]
英文:
I have a list which looks like this:
temp=[-39.5, -27.5, -15.5, -3.5, 8.5, 20.5, 32.5, 44.5, 56.5, 68.5, 80.5, 92.5,104.5]
I want to split the list into list of tuple where second element becomes the first element of the tuple
e.g.: Expected output:
temps = [(-39.5, -27.5), (-27.5,-15.5), (-15.5,-3.5), (-3.5,8.5), (8.5,20.5), (20.5,32.5), (32.5,44.5), (44.5,56.5), (56.5,68.5), (68.5,80.5), (80.5,92.5), (92.5,104.5)]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论