- 要判断是否为空,否则 i[0]有问题
- 判断 i[1:]是否为数字(is.digit()), 否则也会报错
while True:
try:
pos=[0,0]
s=input().split(";")
alpha = ['A','S','W','D']
for i in s:
if i == '':
continue
alp = i[0]
num = i[1:]
if alp in alpha and len(i)<=3 and num.isdigit():
if alp == 'A':
pos[0]-=int(num)
elif alp == 'D':
pos[0] +=int(num)
elif alp == 'W':
pos[1] += int(num)
else:
pos[1] -= int(num)
print(str(pos[0])+','+str(pos[1]))
except:
break