You are tasked with creating a program that calculates and returns the number of vowels…
- User
You are tasked with creating a program that calculates and returns the number of vowels in a given string. Vowels are defined as the letters 'a', 'e', 'i', 'o', and 'u', both in lowercase and uppercase. Input:
• A single line containing a string of alphanumeric characters, spaces, and punctuation marks.
Output:
• An integer representing the count of vowels in the given string.
Sample Input:
Hello, World!
Sample Output:
3
Explanation:
In the given sample input, the string is "Hello, World!".
-
The vowels in the string are 'e', 'o', and 'o'.
-
The count of vowels is 3, so the program should return 3 as the output.
Constraints:
• The input string can have a maximum length of 10^5 characters.
The input string may contain both uppercase and lowercase letters.
• The input string may contain spaces and punctuation marks, which should be ignored when counting vowels
• The program should handle both ASCII and Unicode characters as vowels.
• The program should be case-insensitive, meaning 'A' and 'a' are considered the same vowel.
This is code template give me solution here: Def_count_vowles(input):
count = 0
Write your code here
return count don't explain only give correct answer
-
- Assistant
def count_vowels(input): count = 0 vowels = set('aeiouAEIOU') for char in input: if char in vowels: count += 1 return count