Home > Software design >  Write a Python program to test whether a passed letter is a vowel or not
Write a Python program to test whether a passed letter is a vowel or not

Time:09-17

def fun(str):

    vowel = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']

    if str == vowel:

        print ("It is a vowel")
    else:
        print ("it is not vowel")
fun('a')
fun('O')

CodePudding user response:

Here is the solution:

def fun(str):
    vowel = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']

    if str in vowel:

        print ("It is a vowel")
    else:
        print ("it is not vowel")

fun('a')
fun('O')

CodePudding user response:

Not quite. Something more like:

 vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']

 def is_vowel():
     letter = input()
     if letter in vowels:
         return("Is a vowel")
     else:
         return("is not a vowel")
  • Related