目前写了判断元音的code如下
word = input()
count = 0
a = e = i = o = u = 0
for num in word.lower():
if num in 'a':
a = 1
elif num in 'e':
e = 1
elif num in 'i':
i = 1
elif num in 'o':
o = 1
elif num in 'u':
u = 1
count = a + e + i + o + u
print(count)
自己觉得这code看起来很笨......想问是不是有更好的写法,
另外也想问for num in word.lower()这行for的运作是怎么样呢?
知道word.lower()是变小写的意思,
但num in word.lower()的意思看了很久还是不太能理解> <