题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
input_str = input() coordinates = input_str.split(";") x,y =0,0 for coord in coordinates: if len(coord)<2: continue direction = coord[0] distance_str = coord[1:] if not distance_str.isdigit(): continue distance = int(distance_str) if direction == "A": x -= distance elif direction == "D": x += distance elif direction == "W": y += distance elif direction == "S": y -= distance print("{},{}".format(x,y))