This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- readline(prompt = "Enter Sentence: " ) # Ask user to enter word or sentence | |
#split the sentence into characters and store them as list | |
sentence = as.list(strsplit(x, "" )[[1]]) | |
vowels = list("a","e","i","o","u") # store vowels as a list | |
# check for vowels in the sentence and print TRUE for every vowel found | |
print( vowels %in% sentence ) | |
# print the letters that appear in the vowel list and sentence list | |
print((intersect(vowels,sentence))) | |
# print the length of the string in line 8 which is the number of vowels present |