commands = "URR"
x = 0
y = 0
for c in commands:
if c == 'U':
y += 1
elif c == 'D':
y -= 1
elif c == 'L':
x -= 1
elif c == 'R':
x += 1
distance = abs(x) + abs(y)
print(distance)
To embed this project on your website, copy the following code and paste it into your website's HTML: