num = [1,2,3,4]
a = "RDD"

for i in range(len(a)):
    if a[i] == "R":
       num = num[::-1] 
    elif a[i] == "D":
        num.remove(num[0])

print(num)

Embed on website

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