题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
str = input().split(";") b = ["W","A","S","D"] x = 0 y = 0# 确定初始坐标 for a in str: if len(a) >= 2 and a[0] in b and a[1:].isdigit(): # 判断字符串长度大于二并且首字母是WASD并且其他为数字 c = int(a[1:]) if a[0] == 'A': x -= c elif a[0] == 'S': y -= c elif a[0] == 'W': y += c elif a[0] == 'D': x += c print(f"{x},{y}")