尋找有幾個母音
2025/11/24 09:13
瀏覽29
迴響0
推薦0
引用0
程式碼:
s = input("請輸入一串字串:")
count = 0
for ch in s:
if ch.lower() in "aeiou": # .lower() 讓大小寫都能判斷
count += 1
print("母音有:", count, "個")
功能說明
-
ch.lower():把字元變小寫,A/E/I/O/U 也能偵測 -
in "aeiou":判斷 ch 是否是母音 -
count += 1:計數器加 1
限會員,要發表迴響,請先登入



