Exercise: working with sequences
Write a function that accepts one argument, a string, and counts the number of vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) in that string.
When you call the function with an all-lowercase string as an argument, your function should print the number of vowels in that string.
countVowels('bananarama')
# prints: Vowel count: 5
Where to write and run the code
You can do this a number of ways. Use whatever works for you. Here are some options:
- Create a
.py
file and write your code in there. Run the file at the command line:python my-filename.py
- Create a
.py
file and write your code in there. Run the file using the terminal in VS Code. - Write and run your code in the Python REPL (just type
python
at the command line and you will see the>>>
prompt, which will let you start typing Python). - There is also a Python REPL built into VS Code that you could use.