Write a python program to check whether the first and last letters of the given word is vowel or not

In this source code example, we will write a python program to check whether the first and last letters of the given word are vowels or not.

Program:

def vowels(word):
    if (word[0] in 'AEIOU' or word[0] in 'aeiou'):
        if (word[len(word) - 1] in 'AEIOU' or word[len(word) - 1] in 'aeiou'):
            return 'First and last letter of ' + word + ' is vowel'
        else:
            return 'First letter of ' + word + ' is vowel'
    else:
        return 'Not a vowel'

print(vowels('apple'))

Output:

First and last letter of apple is vowel

Comments