美文网首页
c05ex06.py

c05ex06.py

作者: 特丽斯纳普 | 来源:发表于2018-03-30 20:31 被阅读0次
# c05ex06.py
#     Numerology of a full name


def main():
    print("This program computes the 'number value' of a name")
    print()

    names = input("Enter a name: ")

    # Create a string of all the letters -- avoids nested loop
    letters = "".join(names.split())
    total = 0
    for letter in letters:
        total = total + ord(letter.lower()) - ord('a') + 1

    print("The value is:", total)

main()

相关文章

网友评论

      本文标题:c05ex06.py

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