题解 | 坐标移动

坐标移动

https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

s = input().split(";")[0:-1]

print(s)

x = 0y = 0

for item in s:cnt = 0for c in item:if c.isalpha():cnt += 1

if cnt!=1:
    continue
cnt = len(item)-cnt
if cnt<=0:
    continue
drection = item[0]
num = int(item[1:])

if num >=100:
    continue
if drection=='W':
    y += num
elif drection=='S':
    y -= num
elif drection=='A':
    x -= num
elif drection=='D':
    x += num
else:
    continue
print(f"{x},{y}")

我代码到底哪里有问题啊,一直报错:

全部评论
放到本地IDE就没问题,我真服了
点赞 回复 分享
发布于 05-01 23:48 甘肃

相关推荐

HoePointer:把重点可以标黑,简历精简一下,然后把你的项目放在 github 或者 gitee 上面,readme 写好看一点(一般面试官有可能会翻你的网页)
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务