Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- #function to count the number of vowels of a nominated word
- def countvowels(word,counter):
- vowels = "aeiou" #list of vowels to compare against the word
- for letter in word:
- x = 0
- for vowel in vowels:
- if vowels[x] ==letter: #cycle through the vowels to compare with each letter
- counter +=1
- break
- x += 1
- return word, counter #return the number of vowels
- counter = 0
- word = input("Enter a word to count the number of vowels: " )
- wordcount = countvowels(word, counter)
- print("in the word " + wordcount[0] + " there are " + str(wordcount[1])+ " vowels")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement