题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
route = input() route_list = route.split(";") #变成列表,["A10", "S20", ...] loc = [0,0] for i in route_list: if len(i) < 2 or len(i)>3: continue elif i[0] == "A" and i[1:].isdigit(): loc[0] -= int(i[1:]) elif i[0] == "D" and i[1:].isdigit(): loc[0] += int(i[1:]) elif i[0] == "W" and i[1:].isdigit(): loc[1] += int(i[1:]) elif i[0] == "S" and i[1:].isdigit(): loc[1] -= int(i[1:]) else: continue print("{},{}".format(loc[0],loc[1]))