I have been tasked with doing a cardtrick that simulates a sequence of cards. The sequence is that the first card is taken out and placed at the bottom, the second card is placed on the table. This process is repeated until all cards have been laid on the table. If you have the order that is given in "Q_kort",you will lay out the cards in order of size (1, 2, 3... etc). Don't know how to do the process. Trying a forloop but it treats all elements the same. How do you make it so that it becomes every other element? We should do it with an Array. Below is what I got but doesnt really work.
from array import array
Q_kort = array("i", [7, 1, 12, 2, 8, 3, 11, 4, 9, 5, 13, 6, 10])
class Kort:
def __init__(self, Q_kort):
self.__Q_kort = Q_kort
def enqueue(self, x):
sist = self.__Q_kort.append(x)
return sist
def dequeue(self):
forst = self.__Q_kort.pop(0)
return forst
def magic():
kort = Kort(Q_kort)
for element in Q_kort:
kort.dequeue()
kort.enqueue(element)
print(element)
magic()