Count the vowels · 数元音字母
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
This one builds on a lesson you haven't finished yet. Do that lesson first: · 此任务基于您尚未完成的课程。请先完成以下课程:
Python Basics · Python 基础 · Functions · 函数 →
English
Count the vowels
Count how many characters of a string are vowels — a, e, i, o, u — treating capitals and lowercase the same.
Lowercase the string first with s.lower() so you only have five letters to check. The expression ch in "aeiou" is True when ch is one of them.
中文
数元音字母
数一数字符串中有多少个字符是元音 —— a、e、i、o、u —— 大写和小写视为相同。
先用 s.lower() 把字符串转成小写,这样只需检查五个字母。表达式 ch in "aeiou" 在 ch 是其中之一时为 True。
Write count_vowels(s): return how many letters in s are vowels (a, e, i, o, u), case-insensitive. · 编写 count_vowels(s):返回 s 中元音字母(a、e、i、o、u)的个数,不区分大小写。
Click Run to see the output here. · 点击“运行”查看此处输出。