from collections import deque

N = 6
cards = deque(range(1, N + 1))

while len(cards) > 1:
    cards.popleft()
    cards.append(cards.popleft()) 
print(cards[0])

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: