题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import sys ASWD = input().split(';') def move(direction,x,y): if len(direction) <2 or direction[:1] not in ['A','S','W','D']: return (x,y) elif direction[1:].isdigit(): if direction[0:1] == 'A': x -= int(direction[1:]) if direction[0:1] == 'S': y -= int(direction[1:]) if direction[0:1] == 'W': y += int(direction[1:]) if direction[0:1] == 'D': x += int(direction[1:]) return x,y x,y = 0 ,0 for i in ASWD: x,y = move(i,x,y) print(f"{x},{y}")