当27或28出现的时候,当它是27的时候,我怎么做一个列表和切片呢?它后面的所有数字都会进入顶部,28之前的任何数字都会进入底部。以前我只有几个函数涉及交换它,但我不确定它是否有助于这个函数。你知道吗
>>> list = [1,2,3,28,4,5,6,27,7,8,9]
>>> list = [7,8,9,28, 4,5,6,27,1,2,3]
def triple_cut(cards):
if 27 and 28 in cards:
return cards[(index(27)):end] + cards[(index(28)):(index(27))] + cards[:(index(28))]
逻辑应该是这样的,但我不能做索引出于某种原因谁能帮我修复代码,使其工作
使用
cards.index(27)
和cards.index(28)
相关问题 更多 >
编程相关推荐