美文网首页
c05ex10.py

c05ex10.py

作者: 特丽斯纳普 | 来源:发表于2018-03-30 20:33 被阅读0次
    # c05ex10.py
    #   Average word length
    
    
    def main():
        print("Average word length")
        print()
    
        phrase = input("Enter a phrase: ")
    
        # using accumulator loop
        count = 0
        total = 0
        for word in phrase.split():
            total = total + len(word)
            count = count + 1
    
        print("Average word length", total / count)
    
    main()
    

    相关文章

      网友评论

          本文标题:c05ex10.py

          本文链接:https://www.haomeiwen.com/subject/tcqwcftx.html