题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
a = input().split(';') axis = [0,0] move_dict1 = {'A': -1, 'D': 1, 'W': 0, 'S': 0} move_dict2 = {'A': 0, 'D': 0, 'W': 1, 'S': -1} for i in a: try: move = i[0] length = int(i[1:]) axis[0] += move_dict1[move] * length axis[1] += move_dict2[move] * length except: continue print('{},{}'.format(axis[0],axis[1]))