推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
s04
V2EX  ›  Python

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

  •  
  •   s04 · Jun 17, 2018 · 3734 views
    This topic created in 2899 days ago, the information mentioned may be changed or developed.
    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 是一个字符串而不是这个列表的索引值。
    15 replies    2018-06-17 19:33:00 +08:00
    s04
        1
    s04  
    OP
       Jun 17, 2018
    lijsh
        2
    lijsh  
       Jun 17, 2018
    好久没玩了,精神上支持一下。

    不是有别人的解答可以参考的吗
    hustfox
        3
    hustfox  
       Jun 17, 2018 via Android
    git 打开 404。要索引可以用:for i,w in enumerate(split_words)呀
    s04
        4
    s04  
    OP
       Jun 17, 2018
    @lijsh 没做完,看不到
    s04
        5
    s04  
    OP
       Jun 17, 2018
    @hustfox 代码就 1L 主题那部分,2L 是一样的内容
    lijsh
        6
    lijsh  
       Jun 17, 2018
    @s04 #4 是哪个问题,我看看我做过了没
    Sanko
        7
    Sanko  
       Jun 17, 2018 via Android
    陷入江局
    hustfox
        8
    hustfox  
       Jun 17, 2018 via Android
    @s04 额,Python 不是根据缩进来的么?贴出来的完全没缩进呀
    s04
        9
    s04  
    OP
       Jun 17, 2018
    s04
        11
    s04  
    OP
       Jun 17, 2018
    s04
        12
    s04  
    OP
       Jun 17, 2018
    @Kagari 应该是我没有变成公开的导致不能直接打开吧
    hustfox
        13
    hustfox  
       Jun 17, 2018   ❤️ 1
    我试了是返回 True 的呀。另外,return True 后面 break 就没用了;最后的判断 if count == 3 也没用吧
    s04
        14
    s04  
    OP
       Jun 17, 2018
    @hustfox 刚刚我吧 if count ==3 改成 !=3 就行了。我被 IDE ( pycharm )的返回结果:进程完成,退出码为 0 给误导了 QAQ。
    s04
        15
    s04  
    OP
       Jun 17, 2018
    @Sanko 你是想上枪毙名单吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3509 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 11:15 · PVG 19:15 · LAX 04:15 · JFK 07:15
    ♥ Do have faith in what you're doing.