A word is considered valid if it meets all of the following conditions:
-
It has a minimum length of 3.
-
It contains only digits (
0
-
9
) and English letters (uppercase and lowercase).
-
It includes at least one vowel.
-
It includes at least one consonant.
You are given a string word. Return True if word is valid, otherwise return False.
Function Signature
def is_valid_word(word: str) -> bool:
Rules
-
'a'
,
'e'
,
'i'
,
'o'
,
'u'
and their uppercase forms are vowels.
-
A consonant is an English letter that is not a vowel, in either case.
'y'
and
'Y'
are consonants.
-
Digits are allowed and count toward the length, but they are neither vowels nor consonants.
-
Any
'@'
,
'#'
or
'$'
makes the word invalid.
Constraints
-
1 <= len(word) <= 20
-
word
consists of English uppercase and lowercase letters, digits,
'@'
,
'#'
, and
'$'
.
Examples
Input: word = "234Adas"
Output: True
The word has length 7 and every character is a digit or a letter. It contains the vowels 'A' and 'a' and the consonants 'd' and 's'.
Input: word = "b3"
Output: False
The word has length 2, which is less than the minimum length of 3.
Input: word = "Ae123"
Output: False
The length is 5 and all characters are allowed, and 'A' and 'e' are vowels. The digits do not count as consonants, so the word has no consonant.