如何让Python计算一个单词中有多少个字母? [英] How do i make Python count how many letters are in a word?
本文介绍了如何让Python计算一个单词中有多少个字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个实验室为我的编程类,我需要知道如何使python计数字中有多少字母排除空格。任何人可以帮助我吗?这是我到目前为止。
I have a lab for my programming class and i need to know how to make python count how many letters are in a word excluding spaces. Can anyone help me out? This is what i have so far.
def Na():
Name = raw_input("What is your name? : ")
count [char]
Na()
推荐答案
sum(c.isalpha() for c in Name)
这篇关于如何让Python计算一个单词中有多少个字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文