# Create a function to test whether or not a character is a vowel def is_vowel(char): all_vowels = 'aeiouAEIOU' return char in all_vowels # Take input from the user char = input("Enter a character: ") # Print result if is_vowel(char): print(char, "is a vowel.") else: print(char, "is not a vowel.")
And now JS // Create a variable that holds the string let str = "This is a test!"; // Iterate through each character in the string for (let char of str) { // Check for each vowel if (char === "a" || char === "e" || char === "i" || char === "o" || char === "u") { // If a vowel is found, print it out console.log(char); } }
# Create a function to test whether or not a character is a vowel
def is_vowel(char):
all_vowels = 'aeiouAEIOU'
return char in all_vowels
# Take input from the user
char = input("Enter a character: ")
# Print result
if is_vowel(char):
print(char, "is a vowel.")
else:
print(char, "is not a vowel.")
And now JS
// Create a variable that holds the string
let str = "This is a test!";
// Iterate through each character in the string
for (let char of str) {
// Check for each vowel
if (char === "a" || char === "e" || char === "i" || char === "o" || char === "u") {
// If a vowel is found, print it out
console.log(char);
}
}
First comment