Aug-29-2017, 01:30 PM
I don't know how to combine the function and the program I've already done the codes just not combining it. If I can help on this it will be great :)
Question as follows:
Write a program that uses a for-loop to ask a user to enter 5 words. The program will then display all the words entered that starts with a vowel only. Your program must use the function start_vowel defined in Question 5. Below is a sample output of the program in Python shell:
Enter a word : Apple
Enter a word : eagle
Enter a word : horse
Enter a word : Hamster
Enter a word : Ostrich
Word that begins with vowels are ['Apple', 'eagle', 'Ostrich']
#The function
def start_vowel(word):
if word[0] == 'A' or 'a' or 'E' or 'e' or 'I' or 'i' or 'O' or 'U' or 'u':
return True
else:
return False
#The program
wordList = []
for word in range(5):
wordList.append(input("Enter a word : "))
print("Word that begins with vowels are " + str(wordList))
Question as follows:
Write a program that uses a for-loop to ask a user to enter 5 words. The program will then display all the words entered that starts with a vowel only. Your program must use the function start_vowel defined in Question 5. Below is a sample output of the program in Python shell:
Enter a word : Apple
Enter a word : eagle
Enter a word : horse
Enter a word : Hamster
Enter a word : Ostrich
Word that begins with vowels are ['Apple', 'eagle', 'Ostrich']
#The function
def start_vowel(word):
if word[0] == 'A' or 'a' or 'E' or 'e' or 'I' or 'i' or 'O' or 'U' or 'u':
return True
else:
return False
#The program
wordList = []
for word in range(5):
wordList.append(input("Enter a word : "))
print("Word that begins with vowels are " + str(wordList))