#Checkio 陷入僵局,求大佬解答

2018-06-17 14:09:48 +08:00
 s04
def checkio(words: str) -> bool:
split_words = words.split()
count = 0
for w in split_words:
if w.isalpha():
count += 1
while count == 3:
return True
break
elif w.isdigit():
count = 0
if count == 3:
return True


checkio('one two 3 four five six 7 eight 9 ten eleven 12')

本人千方百计试图将 for 循环里边的 count 变为 3 后返回 true 后解决题目,但不管如何返回的都是 False.
除此之外,为什么 for 循环里边 w 是一个字符串而不是这个列表的索引值。
2974 次点击
所在节点    Python
15 条回复
s04
2018-06-17 14:11:47 +08:00
lijsh
2018-06-17 15:23:14 +08:00
好久没玩了,精神上支持一下。

不是有别人的解答可以参考的吗
hustfox
2018-06-17 15:23:47 +08:00
git 打开 404。要索引可以用:for i,w in enumerate(split_words)呀
s04
2018-06-17 16:16:04 +08:00
@lijsh 没做完,看不到
s04
2018-06-17 16:17:30 +08:00
@hustfox 代码就 1L 主题那部分,2L 是一样的内容
lijsh
2018-06-17 16:18:46 +08:00
@s04 #4 是哪个问题,我看看我做过了没
Sanko
2018-06-17 16:45:27 +08:00
陷入江局
hustfox
2018-06-17 17:10:32 +08:00
@s04 额,Python 不是根据缩进来的么?贴出来的完全没缩进呀
s04
2018-06-17 17:25:01 +08:00
Kagari
2018-06-17 18:16:20 +08:00
s04
2018-06-17 18:27:03 +08:00
s04
2018-06-17 18:34:46 +08:00
@Kagari 应该是我没有变成公开的导致不能直接打开吧
hustfox
2018-06-17 19:19:33 +08:00
我试了是返回 True 的呀。另外,return True 后面 break 就没用了;最后的判断 if count == 3 也没用吧
s04
2018-06-17 19:30:32 +08:00
@hustfox 刚刚我吧 if count ==3 改成 !=3 就行了。我被 IDE ( pycharm )的返回结果:进程完成,退出码为 0 给误导了 QAQ。
s04
2018-06-17 19:33:00 +08:00
@Sanko 你是想上枪毙名单吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/463717

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX