Knowee
Questions
Features
Study Tools

Let name=[“nispal”, “tilak”, “bharat”, “rijesh”, “soniya”]. Display the numbers of vowels in eachname of the given list. Display message like :“nispal contains 2 vowels

Question

Let name=[“nispal”, “tilak”, “bharat”, “rijesh”, “soniya”]. Display the numbers of vowels in eachname of the given list. Display message like :“nispal contains 2 vowels

🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a step-by-step solution in Python:

  1. First, define the list of names:
names = ["nispal", "tilak", "bharat", "rijesh", "soniya"]
  1. Create a function to count the vowels in a string:
def count_vowels(name):
    vowels = 'aeiou'
    return sum(1 for char in name if char in vowels)
  1. Loop through the list of names, count the vowels in each name, and print the result:
for name in names:
    print(f"{name} contains {count_vowels(name)} vowels")

This will display the number of vowels in each name in the list.

This problem has been solved

Similar Questions

Define a class to accept a string and convert it into uppercase. Count and display thenumber of vowels in it.

Write program to display your name and perform following operations on it: Display n characters from left. (Accept n as input from the user)Count the number of vowels. Reverse it. The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of comments within the code. The descriptive part of your response must be at least 200 words.

Read any string and display the vowels

Define a class to accept a string and convert it into uppercase. Count and display thenumber of vowels in it.Input: roboticsOutput: ROBOTICSNumber of vowels: 3

#Write a Python function count_vowels(text) that takes a string as input and returns the count of vowels (a, e, i, o, u) in the input string, ignoring case.

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.