from collections import deque

calculation = "RDD"
dq = deque([10, 20, 30, 40])

for i in range(len(calculation)):
    if calculation[i] == "R":
        dq.rotate(1)
    else:
        dq.popleft()

print(dq)

Embed on website

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