I have a list where I want to move the elements with '1' to the end of the list.
For example, I have the list: Test = [['dogs',2], ['cats', 3], ['dogs',4] , ['dogs', 1], ['cats', 11], ['cats',1], ['birds',1], ['birds', 12]]
I want to move all lists with a "1" as their second element to the end of the list "Test". So far,
def score_hand(hand):
#Setting the appropriate values for the cards and moving the ones to the back
for card in hand:
if hand[hand.index(card)][1] == 1:
hand.append(card)
hand.remove(card)
However, when doing this, my loop skips an element. I'm a new coder and I'm unsure of what to do.