r, c = 0, 0
moves = ['U', 'U', 'R', 'L', 'D']

for move in moves:
    new_r, new_c = r, c

    if move == 'U':
        new_r += 1
    elif move == 'D':
        new_r -= 1
    elif move == 'R':
        new_c += 1
    elif move == 'L':
        new_c -= 1

    if -100 <= new_r <= 100 and -100 <= new_c <= 100:
        r, c = new_r, new_c

print(r + c)

Embed on website

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