英語裡母音開頭的詞前面用 an,其他用 a。is_vowel(letter) 已經寫好了。寫 with_article(word),用它看第一個字母,返回 "an apple" 或 "a pear"。大寫開頭也算。
with_article("apple")→'an apple'with_article("pear")→'a pear'def is_vowel(letter):
return letter.lower() in "aeiou"
def with_article(word):
# 在這裡寫:第一個字母是母音,就返回 "an " + word
return "a " + word
寫好了先點「執行」試試示例,沒問題再點「提交」。