Advertisement
Adehumble

Week3 Coding Exercise 1

Feb 11th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1.  
  2. #1
  3. #This program is written to generate/find the number of vowels in any sentence/word with repetition.
  4. #It's design to be case-insentitive: Hence "i" also implies "I"
  5. #In addition, this program is also diligent to print out the list of vowels found in a particular word/sentence.
  6. #Happy coding!
  7.  
  8. def vowel_count(user_input):
  9.     vowels=["a", "e", "i", "o", "u"]
  10.     wordvowels=[]
  11.     count=0
  12.     for i in user_input:
  13.         if i==vowels[0]:
  14.             wordvowels.append(vowels[0])
  15.             count+=1
  16.         elif i==vowels[1]:
  17.             wordvowels.append(vowels[1])
  18.             count+=1
  19.         elif i==vowels[2]:
  20.             wordvowels.append(vowels[2])
  21.             count+=1
  22.         elif i==vowels[3]:
  23.             wordvowels.append(vowels[3])
  24.             count+=1
  25.         elif i==vowels[4]:
  26.             wordvowels.append(vowels[4])
  27.             count+=1
  28.     if wordvowels==[]:
  29.         print("There are no vowels in your input", user_input)
  30.     else:
  31.         print("There are",count,"vowels in",user_input)
  32.         print("They are:", end=" ")
  33.         print(wordvowels)
  34.    
  35. print("This program is written to return the number of vowels in a word.\nFeel free!")
  36. print("-----"*24)
  37.  
  38. word=input("please, enter any word of your choice:  ").lower()
  39. vowel_count(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement