Answer to Question #310162 in Python for xxx

Question #310162

1.Count how many vowels (a, e, I, o, u) in a word.


Code:

import random

import string


word = ""

for i in range(20):

  word += random.choice(string.ascii_lowercase)


print(word)

# write your code here


1
Expert's answer
2022-03-12T01:33:24-0500
import random
import string

word = ""
for i in range(20):
  word += random.choice(string.ascii_lowercase)
print(word)

chars = ['a', 'e', 'I', 'o', 'u']
count = 0
for i in word:
  if i in chars:
    count += 1
print(f'Total vowels (a, e, I, o, u): {count}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS