次の関数で少し問題が発生しています。単純なリスト メソッドを使用して、doc-string に示されている例を実現する方法を知りたいです。
# The values of the two jokers.
JOKER1 = 27
JOKER2 = 28
def triple_cut(deck):
'''(list of int) -> NoneType
Locate JOKER1 and JOKER2 in deck and preform a triple cut.\
Everything above the first joker goes at the bottom of the deck.\
And everything below the second joker goes to the top of the deck.\
Treat the deck as circular.
>>> deck = [1, 2, 27, 3, 4, 28, 5, 6, 7]
>>> triple_cut(deck)
>>> deck
[5, 6, 7, 27, 3, 4, 28, 1, 2]
>>> deck = [28, 1, 2, 3, 27]
>>> triple_cut(deck)
>>> deck
[28, 1, 2, 3, 27]
'''
# obtain indices of JOKER1 and JOKER2
j1 = deck.index(JOKER1)
j2 = deck.index(JOKER2)
# determine what joker appears 1st and 2nd
first = min(j1, j2)
second = max(j1, j2)
# use slice syntax to obtain values before JOKER1 and after JOKER2
upper = deck[0:first]
lower = deck[(second + 1):]
# swap these values
upper, lower = lower, upper
int のリストを実行すると。27 と 28 を含む場合、この関数はリストに対して何もしません。何が問題なのかわからないのですが、助けてもらえますか?