Dec-30-2020, 06:44 PM
in addition to excellent advises from @jefsummers and @deanhystad - you can also use list comprehension
txt = "Count the number of vowels in this sentence." vowels = "aeiouAEIOU" cnt = sum(ch in vowels for ch in txt) print(f'Number of vowels in the sentence is {cnt}')
Output:Number of vowels in the sentence is 13
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs