Count the vowels · นับสระ
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() เพื่อให้มีเพียงห้าตัวอักษรที่ต้องตรวจสอบ. Expression ch in "aeiou" จะเป็น True เมื่อ ch เป็นหนึ่งในนั้น
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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่