python 练习题-坐标移动
地址:
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29?tpId=37&tqId=21240&rp=1&ru=%2Fta%2Fhuawei&qru=%2Fta%2Fhuawei%2Fquestion-ranking&tab=answerKey
1 n = input() 2 l = n.split(';') 3 pos = [0,0] 4 5 for i in l: 6 if len(i) >1 and len(i) <4: 7 iOne = i[0] 8 iTwo = i[1:] 9 if (iOne in ['W',"A",'S','D']) and iTwo.isdigit(): 10 if iOne == 'A': 11 pos[0] = pos[0] - int(iTwo) 12 if iOne == 'D': 13 pos[0] = pos[0] + int(iTwo) 14 if iOne == 'W': 15 pos[1] = pos[1] + int(iTwo) 16 if iOne == 'S': 17 pos[1] = pos[1] - int(iTwo) 18 print(str(pos[0])+','+str(pos[1]))