0
0
Pythonprogramming~15 mins

Iterating over strings in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Iterating over strings
📖 Scenario: You are working on a simple text analyzer that looks at each letter in a word to count vowels. This is useful for understanding how words are built and can help in language learning apps.
🎯 Goal: Build a small program that goes through each letter in a word and counts how many vowels it has.
📋 What You'll Learn
Create a string variable with a specific word
Create a variable to count vowels
Use a for loop to go through each letter in the string
Check if each letter is a vowel
Print the total count of vowels
💡 Why This Matters
🌍 Real World
Counting vowels helps in language learning apps and text analysis tools to understand word structure.
💼 Career
Knowing how to loop over strings and check characters is a basic skill useful in many programming jobs, including data processing and software development.
Progress0 / 4 steps
1
Create the word string
Create a string variable called word and set it to the exact value "education".
Python
Need a hint?

Use quotes to create a string. For example: word = "hello"

2
Set up the vowel counter
Create a variable called vowel_count and set it to 0 to start counting vowels.
Python
Need a hint?

Use = 0 to start counting from zero.

3
Count vowels using a for loop
Use a for loop with the variable letter to go through each character in word. Inside the loop, use an if statement to check if letter is one of the vowels 'a', 'e', 'i', 'o', or 'u'. If it is, add 1 to vowel_count.
Python
Need a hint?

Remember, you can check if a letter is in a string of vowels using if letter in 'aeiou':

4
Print the total vowel count
Write a print statement to display the text "Number of vowels:" followed by the value of vowel_count using an f-string.
Python
Need a hint?

Use print(f"Number of vowels: {vowel_count}") to show the result.