Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

[Solved] Check vowels #93 #116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/vowels/checkvowels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def is_character_vowel(char):
"""
Check if a given character is a vowel.

Parameters:
- char (str): The character to be checked.

Returns:
- bool: True if the character is a vowel, False otherwise.
"""
vowels = "aeiouAEIOU"
Rishitha-VasiReddy marked this conversation as resolved.
Show resolved Hide resolved
return char in vowels

def main():
user_input = input("Enter a character: ")
"""
Main function to get user input and determine if the entered character is a vowel.
"""

if len(user_input) == 1 and user_input.isalpha():
if is_character_vowel(user_input):
print(f"The character '{user_input}' is a vowel.")
else:
print(f"The character '{user_input}' is not a vowel.")
else:
print("Please enter a single alphabetic character.")

if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions tests/vowels/test_checkvowels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

from vowels.checkvowels import is_character_vowel


def test_is_character_vowel():
assert is_character_vowel('a') == True
assert is_character_vowel('b') == False
assert is_character_vowel('A') == True
assert is_character_vowel('1') == False
assert is_character_vowel('@') == False


Loading