Question: Python, I am working on the code down below but I want it to have the method do the counting and then have the counts

Python, I am working on the code down below but I want it to have the method do the counting and then have the counts return to the main() also I want the method to be either set or dictionary. Any help on this is appreciated! The purpose of the code it to have a function named numVowels that is passed a string containing letters, each of which may be in either uppercase or lowercase, and returns a tuple containing the number of vowels and the number of consonants the string contains. Thank you for the help and please post pictures as I am not always sure what the proper indenting should look like. The second picture was of an answer that did not work which was:

import re def countinput(txt): vowels=['a','e','i','o','u'] avowels=0 aconsonants=0 for i in range(0,len(txt)-1): if txt[i] in vowels: avowels=avowels+1 else: aconsonants=aconsonants+1 return [avowels,aconsonants]Python, I am working on the code down below but I wantit to have the method do the counting and then have the

import re def countinput(txt): z re.sub(r"\W", "", txt) vowels = ' aeiouy' avowel s = 0 aconsonants = 0 for c in z: if c in vowels avowels += 1 else: aconsonants += 1 print('This string has n1) vowels and n2} consonents'.format (n1-avowels, n intxt = input(' Please type in a string of characters: ').lower() countinput(intxt) Ln: 15 Col: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!