题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
s = input().split(";") x,y = 0,0 for word in s: if len(word) < 2: continue elif word[0] == 'A' and word[1:].isdigit(): x -= int(word[1:]) elif word[0] == 'D' and word[1:].isdigit(): x += int(word[1:]) elif word[0] == 'W' and word[1:].isdigit(): y += int(word[1:]) elif word[0] == 'S' and word[1:].isdigit(): y -= int(word[1:]) print(f"{x},{y}")
主要是判断每一个输入是否符合格式,符合就操作,不符合就下一个